Commit 3a1588f7 by zhiwj

导购

parent 454ec291
......@@ -52,6 +52,8 @@ public class ClerkPositionDTO implements Serializable {
private Integer status;
private int seq;
private Integer relNum;
public Integer getClerkPositionId() {
return clerkPositionId;
}
......@@ -123,4 +125,12 @@ public class ClerkPositionDTO implements Serializable {
public int getSeq() {
return seq;
}
public void setRelNum(Integer relNum) {
this.relNum = relNum;
}
public Integer getRelNum() {
return relNum;
}
}
package com.gic.store.dao.mapper;
import com.gic.store.entity.TabClerk;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface TabClerkMapper {
/**
......@@ -73,4 +75,7 @@ public interface TabClerkMapper {
TabClerk getClerkByCode(@Param("enterpriseId") Integer enterpriseId, @Param("clerkCode") String clerkCode, @Param("storeInfoId") Integer storeInfoId);
TabClerk getClerkLeaderByStoreInfoId(@Param("enterpriseId") Integer enterpriseId, @Param("storeInfoId") Integer storeInfoId);
@MapKey("clerkPositionId")
Map<Integer, Map<String, Object>> countMapByPosition(@Param("enterpriseId") Integer enterpriseId, @Param("ids") List<Integer> positionList);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.gic.store.dto.ClerkDTO;
import com.gic.store.entity.TabClerk;
import java.util.List;
import java.util.Map;
/**
* @ClassName: ClerkService
......@@ -121,4 +122,5 @@ public interface ClerkService {
TabClerk getClerkLeaderByStoreInfoId(Integer enterpriseId, Integer storeInfoId);
Map<Integer, Integer> countMapByPosition(Integer enterpriseId, List<Integer> positionList);
}
......@@ -10,9 +10,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -164,4 +162,14 @@ public class ClerkServiceImpl implements ClerkService {
return tabClerkMapper.getClerkLeaderByStoreInfoId(enterpriseId, storeInfoId);
}
@Override
public Map<Integer, Integer> countMapByPosition(Integer enterpriseId, List<Integer> positionList) {
Map<Integer, Map<String, Object>> map = tabClerkMapper.countMapByPosition(enterpriseId, positionList);
HashMap<Integer, Integer> resultMap = new HashMap<>();
for (Map.Entry<Integer, Map<String, Object>> entry : map.entrySet()) {
resultMap.put(entry.getKey(), Integer.valueOf(entry.getValue().get("relNum").toString()));
}
return resultMap;
}
}
......@@ -10,17 +10,22 @@ import com.gic.store.dto.ClerkPositionDTO;
import com.gic.store.entity.TabClerkPosition;
import com.gic.store.service.ClerkPositionApiService;
import com.gic.store.service.ClerkPositionService;
import com.gic.store.service.ClerkService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("clerkPositionApiService")
public class ClerkPositionApiServiceImpl implements ClerkPositionApiService {
@Autowired
private ClerkPositionService clerkPositionService;
@Autowired
private ClerkService clerkService;
@Override
public ServiceResponse<Void> save(ClerkPositionDTO clerkPositionDTO) {
......@@ -65,6 +70,11 @@ public class ClerkPositionApiServiceImpl implements ClerkPositionApiService {
for (int i = 0; i < positionDTOList.size(); i++) {
positionDTOList.get(i).setSeq(i + 1);
}
List<Integer> positionList = clerkPositionDTOPage.getResult().stream().map(ClerkPositionDTO::getClerkPositionId).collect(Collectors.toList());
Map<Integer, Integer> map = clerkService.countMapByPosition(enterpriseId, positionList);
for (ClerkPositionDTO clerkPositionDTO : clerkPositionDTOPage.getResult()) {
clerkPositionDTO.setRelNum(map.getOrDefault(clerkPositionDTO.getClerkPositionId(), 0));
}
}
return EnterpriseServiceResponse.success(clerkPositionDTOPage);
}
......
......@@ -334,7 +334,6 @@
and store_info_id = #{storeInfoId}
and clerk_code = #{clerkCode}
</select>
<!-- getClerkLeaderByStoreInfoId-->
<select id="getClerkLeaderByStoreInfoId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
......@@ -344,4 +343,18 @@
and position_id = 1
limit 1
</select>
<select id="countMapByPosition" resultType="map">
select
position_id clerkPositionId,
count(*) relNum
from tab_clerk
where enterprise_id = #{enterpriseId}
<if test="null != ids and ids.size > 0">
and position_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
group by position_id
</select>
</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