Commit 2a46bb3c by fudahua

fix

parent c4f41147
...@@ -19,6 +19,7 @@ import com.gic.haoban.manage.api.service.StaffApiService; ...@@ -19,6 +19,7 @@ import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService; import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.service.*;
import com.gic.redis.data.anno.RedisCache;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -816,6 +817,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -816,6 +817,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
@Override @Override
@RedisCache(value = "department-list-cache-${wxEnterpriseId}")
public List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId) { public List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId) {
List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId); List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId);
return list; return list;
......
...@@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONArray; ...@@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse; import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.TestApiService; import com.gic.haoban.manage.api.service.TestApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
...@@ -56,6 +57,9 @@ public class ServiceTest { ...@@ -56,6 +57,9 @@ public class ServiceTest {
@Autowired @Autowired
private TestApiService testApiService; private TestApiService testApiService;
@Autowired
private DepartmentApiService departmentApiService;
private final ExecutorService pools = Executors.newFixedThreadPool(50); private final ExecutorService pools = Executors.newFixedThreadPool(50);
...@@ -63,15 +67,15 @@ public class ServiceTest { ...@@ -63,15 +67,15 @@ public class ServiceTest {
public void test() { public void test() {
int i=2000; int i=2000;
while (i-->0) { while (i-->0) {
int finalI = i; departmentApiService.listAllDepartment(i+"");
pools.execute(new Runnable(){
@Override
public void run() {
testApiService.checkThread(finalI +"",100L);
}
});
} }
}
try {
Thread.sleep(1000000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// @Test // @Test
......
...@@ -23,6 +23,7 @@ import com.gic.haoban.manage.web.qo.GetUserByMemberCodeQo; ...@@ -23,6 +23,7 @@ import com.gic.haoban.manage.web.qo.GetUserByMemberCodeQo;
import com.gic.haoban.manage.web.qo.MemberLoginQo; import com.gic.haoban.manage.web.qo.MemberLoginQo;
import com.gic.haoban.manage.web.vo.AppStaffVo; import com.gic.haoban.manage.web.vo.AppStaffVo;
import com.gic.haoban.manage.web.vo.InfoVo; import com.gic.haoban.manage.web.vo.InfoVo;
import com.gic.haoban.manage.web.vo.StoreMemberVO;
import com.gic.haoban.manage.web.vo.StoreVO; import com.gic.haoban.manage.web.vo.StoreVO;
import com.gic.wechat.api.dto.qywx.UserDTO; import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxCorpApiService; import com.gic.wechat.api.service.qywx.QywxCorpApiService;
...@@ -79,6 +80,9 @@ public class InfoController extends WebBaseController{ ...@@ -79,6 +80,9 @@ public class InfoController extends WebBaseController{
@Autowired @Autowired
private StaffMemberRelationApiService staffMemberRelationApiService; private StaffMemberRelationApiService staffMemberRelationApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
private static Logger logger= LoggerFactory.getLogger(InfoController.class); private static Logger logger= LoggerFactory.getLogger(InfoController.class);
...@@ -185,83 +189,91 @@ public class InfoController extends WebBaseController{ ...@@ -185,83 +189,91 @@ public class InfoController extends WebBaseController{
relatedDTO.setGicEnterpriseId(enterpriseDetailDTO.getEnterpriseId()); relatedDTO.setGicEnterpriseId(enterpriseDetailDTO.getEnterpriseId());
staffMemberRelationApiService.bindMemberAndStaff(relatedDTO); staffMemberRelationApiService.bindMemberAndStaff(relatedDTO);
ServiceResponse<List<DepartmentDTO>> response = departmentApiService.listStoreListByStaffId(staffDTO.getStaffId());
List<DepartmentDTO> result = response.getResult(); List<StaffClerkInfoDTO> result = staffClerkRelationApiService.listBindDetailByStaffId(staffDTO.getStaffId());
List<StoreVO> retList = new ArrayList<>();
if (response.getCode() == 1 && CollectionUtils.isNotEmpty(result)) { // ServiceResponse<List<DepartmentDTO>> response = departmentApiService.listStoreListByStaffId(staffDTO.getStaffId());
// List<DepartmentDTO> result = response.getResult();
List<StoreMemberVO> retList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(result)) {
result.stream().forEach(dto -> { result.stream().forEach(dto -> {
StoreVO VO = new StoreVO(); StoreMemberVO VO = new StoreMemberVO();
VO.setDepartmentId(dto.getDepartmentId()); StoreDTO store = storeService.getStore(dto.getStoreId());
VO.setStoreId(dto.getRelatedId());//为空,则无该值 ClerkDTO clerkDTO = clerkService.getClerkByClerkId(dto.getClerkId());
VO.setStoreName(dto.getDepartmentName()); if (null != store&&clerkDTO!=null) {
VO.setWxEnterpriseId(dto.getWxEnterpriseId()); VO.setStoreId(dto.getStoreId());//为空,则无该值
VO.setStoreImg("");//先置空 VO.setStoreName(dto.getStoreName());
if (org.apache.commons.lang.StringUtils.isNotBlank(dto.getRelatedId())) { VO.setWxEnterpriseId(dto.getWxEnterpriseId());
StoreDTO storeDTO = storeService.getStore(dto.getRelatedId()); VO.setEnterpriseId(store.getEnterpriseId());
if (storeDTO != null) { VO.setStoreImg(store.getImageUrl());//先置空
VO.setEnterpriseId(storeDTO.getEnterpriseId());
VO.setStoreImg(storeDTO.getImageUrl());//先置空 VO.setClerkCode(clerkDTO.getClerkCode());
} VO.setClerkType(clerkDTO.getClerkType());
VO.setStaffId(staffDTO.getStaffId());
VO.setClerkId(clerkDTO.getClerkId());
retList.add(VO);
} }
VO.setCreateTime(dto.getCreateTime());
retList.add(VO); // VO.setDepartmentId(dto.getDepartmentId());
}); });
//塞clerkCOde等基本信息 // //塞clerkCOde等基本信息
List<StaffDepartmentRelatedDTO> relateList = staffDepartmentRelatedApiService.listByStaffId(staffDTO.getStaffId()); // List<StaffDepartmentRelatedDTO> relateList = staffDepartmentRelatedApiService.listByStaffId(staffDTO.getStaffId());
Map<String,StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relateList, "departmentId"); // Map<String,StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relateList, "departmentId");
for(StoreVO VO : retList){ // for(StoreVO VO : retList){
StaffDepartmentRelatedDTO staffDepartmentRelatedDTO = map.get(VO.getDepartmentId()); // StaffDepartmentRelatedDTO staffDepartmentRelatedDTO = map.get(VO.getDepartmentId());
if(staffDepartmentRelatedDTO != null){ // if(staffDepartmentRelatedDTO != null){
String clerkCode = staffDepartmentRelatedDTO.getClerkCode(); // String clerkCode = staffDepartmentRelatedDTO.getClerkCode();
VO.setBindFlag(StringUtils.isEmpty(clerkCode)?0:1); // VO.setBindFlag(StringUtils.isEmpty(clerkCode)?0:1);
VO.setClerkCode(clerkCode); // VO.setClerkCode(clerkCode);
VO.setStaffDepartmentRelatedId(staffDepartmentRelatedDTO.getStaffDepartmentRelatedId()); // VO.setStaffDepartmentRelatedId(staffDepartmentRelatedDTO.getStaffDepartmentRelatedId());
VO.setStaffId(staffDTO.getStaffId()); // VO.setStaffId(staffDTO.getStaffId());
ClerkDTO clerkDTO = clerkService.getClerkByClerkCode(VO.getEnterpriseId(), clerkCode); // ClerkDTO clerkDTO = clerkService.getClerkByClerkCode(VO.getEnterpriseId(), clerkCode);
VO.setClerkId(clerkDTO == null?"":clerkDTO.getClerkId()); // VO.setClerkId(clerkDTO == null?"":clerkDTO.getClerkId());
}else{ // }else{
VO.setBindFlag(0); // VO.setBindFlag(0);
} // }
} // }
//
//
//塞门店店长标志 // //塞门店店长标志
ClerkMainStoreRelatedDTO mainStore = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(enterpriseDTO.getWxEnterpriseId(),staffDTO.getStaffId()); // ClerkMainStoreRelatedDTO mainStore = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(enterpriseDTO.getWxEnterpriseId(),staffDTO.getStaffId());
for(StoreVO VO : retList){ // for(StoreVO VO : retList){
//查gic门店 // //查gic门店
StoreDTO storeDTO = storeService.getStore(VO.getStoreId()); // StoreDTO storeDTO = storeService.getStore(VO.getStoreId());
List<StorePhotoDTO> imgList = storeService.getStoreImages(VO.getStoreId()); // List<StorePhotoDTO> imgList = storeService.getStoreImages(VO.getStoreId());
EnterpriseDetailDTO detail = wxEnterpriseRelatedApiService.getByEnterpriseId(storeDTO.getEnterpriseId()); // EnterpriseDetailDTO detail = wxEnterpriseRelatedApiService.getByEnterpriseId(storeDTO.getEnterpriseId());
VO.setWxEnterpriseRelatedId(detail.getWxEnterpriseRelatedId()); // VO.setWxEnterpriseRelatedId(detail.getWxEnterpriseRelatedId());
//已经绑定的门店 // //已经绑定的门店
if(VO.getBindFlag()==1){ // if(VO.getBindFlag()==1){
String clerkCode = VO.getClerkCode(); // String clerkCode = VO.getClerkCode();
if(StringUtils.isEmpty(clerkCode)){ // if(StringUtils.isEmpty(clerkCode)){
VO.setClerkType(0); // VO.setClerkType(0);
}else{ // }else{
if(storeDTO != null){ // if(storeDTO != null){
//查gic门店店长 // //查gic门店店长
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(storeDTO.getClerkId()); // ClerkDTO clerkDTO = clerkService.getClerkByClerkId(storeDTO.getClerkId());
if(clerkDTO != null){ // if(clerkDTO != null){
//code相同,则置为1 // //code相同,则置为1
if(clerkCode.equals(clerkDTO.getClerkCode())){ // if(clerkCode.equals(clerkDTO.getClerkCode())){
VO.setClerkType(1); // VO.setClerkType(1);
} // }
} // }
} // }
} // }
} // }
if(CollectionUtil.isNotEmpty(imgList)){ // if(CollectionUtil.isNotEmpty(imgList)){
VO.setStoreImg(imgList.get(0).getQcloudImageUrl());; // VO.setStoreImg(imgList.get(0).getQcloudImageUrl());;
} // }
//
if(mainStore != null && mainStore.getStoreId().equals(VO.getStoreId())){ // if(mainStore != null && mainStore.getStoreId().equals(VO.getStoreId())){
VO.setMainStoreFlag(1); // VO.setMainStoreFlag(1);
}else{ // }else{
VO.setMainStoreFlag(0); // VO.setMainStoreFlag(0);
} // }
} // }
user.setStoreList(retList); user.setStoreList(retList);
} }
return resultResponse(HaoBanErrCode.ERR_1, user); return resultResponse(HaoBanErrCode.ERR_1, user);
......
package com.gic.haoban.manage.web.qo; package com.gic.haoban.manage.web.qo;
import com.gic.haoban.manage.web.vo.StoreMemberVO;
import com.gic.haoban.manage.web.vo.StoreVO; import com.gic.haoban.manage.web.vo.StoreVO;
import java.io.Serializable; import java.io.Serializable;
...@@ -13,7 +14,7 @@ import java.util.List; ...@@ -13,7 +14,7 @@ import java.util.List;
public class MemberLoginQo implements Serializable { public class MemberLoginQo implements Serializable {
private String userId; private String userId;
private String corpId; private String corpId;
private List<StoreVO> storeList; private List<StoreMemberVO> storeList;
public String getUserId() { public String getUserId() {
return userId; return userId;
...@@ -31,11 +32,11 @@ public class MemberLoginQo implements Serializable { ...@@ -31,11 +32,11 @@ public class MemberLoginQo implements Serializable {
this.corpId = corpId; this.corpId = corpId;
} }
public List<StoreVO> getStoreList() { public List<StoreMemberVO> getStoreList() {
return storeList; return storeList;
} }
public void setStoreList(List<StoreVO> storeList) { public void setStoreList(List<StoreMemberVO> storeList) {
this.storeList = storeList; this.storeList = storeList;
} }
} }
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
import java.util.Date;
/**
* Created 2018/10/22.
*
* @author hua
*/
public class StoreMemberVO implements Serializable {
private static final long serialVersionUID = 1L;
private String storeId;
private String staffId;
private String storeName;
private String wxEnterpriseId;
private String enterpriseId;
private String clerkCode;
private String clerkId;
private String storeImg;
private int clerkType;
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getClerkCode() {
return clerkCode;
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getStoreImg() {
return storeImg;
}
public void setStoreImg(String storeImg) {
this.storeImg = storeImg;
}
public int getClerkType() {
return clerkType;
}
public void setClerkType(int clerkType) {
this.clerkType = clerkType;
}
}
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