|
|
@ -20,6 +20,7 @@ package com.epmet.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
@ -28,10 +29,7 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.CustomerFunctionDao; |
|
|
|
import com.epmet.dao.CustomerFunctionDetailDao; |
|
|
|
import com.epmet.dao.FunctionCustomizedDao; |
|
|
|
import com.epmet.dao.FunctionShoppingHistoryDao; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.CustomerFunctionDetailDTO; |
|
|
|
import com.epmet.dto.FunctionCustomizedDTO; |
|
|
|
import com.epmet.dto.FunctionShoppingHistoryDTO; |
|
|
@ -40,6 +38,7 @@ import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.CustomerFunctionDetailEntity; |
|
|
|
import com.epmet.entity.CustomerFunctionEntity; |
|
|
|
import com.epmet.entity.FunctionShoppingHistoryEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.redis.CustomerFunctionDetailRedis; |
|
|
|
import com.epmet.service.CustomerFunctionDetailService; |
|
|
|
import com.epmet.service.FunctionShoppingHistoryService; |
|
|
@ -49,6 +48,7 @@ import org.apache.logging.log4j.Logger; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import rx.internal.util.LinkedArrayList; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -73,6 +73,10 @@ public class CustomerFunctionDetailServiceImpl extends BaseServiceImpl<CustomerF |
|
|
|
private CustomerFunctionDao customerFunctionDao; |
|
|
|
@Autowired |
|
|
|
private FunctionShoppingHistoryDao functionShoppingHistoryDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private CustomerFunctionRoleDao customerFunctionRoleDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerFunctionDetailDTO> page(Map<String, Object> params) { |
|
|
@ -133,10 +137,65 @@ public class CustomerFunctionDetailServiceImpl extends BaseServiceImpl<CustomerF |
|
|
|
* @Description 根据所属端和客户Id查询客户定制功能列表 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<FunctionDetailResultDTO> resiAndWorkFunctionDetail(FunctionDetailFromDTO formDTO) { |
|
|
|
//根据客户Id和所属端查询客户定制功能列表数据
|
|
|
|
public List<FunctionDetailResultDTO> resiFunctionDetail(FunctionDetailFromDTO formDTO) { |
|
|
|
List<FunctionDetailResultDTO> restltList = new LinkedList<>(); |
|
|
|
//1.根据客户Id和所属端查询客户定制功能列表数据
|
|
|
|
logger.info(String.format("根据客户Id和所属端查询客户定制功能列表,对应客户Id->%s,所属端->%s", formDTO.getCustomerId(), formDTO.getClientType())); |
|
|
|
List<FunctionDetailResultDTO> list = baseDao.selectFunctionDetailList(formDTO); |
|
|
|
if (null != list && list.size() > NumConstant.ZERO) { |
|
|
|
//1-1.设置自定义json数据(暂时为空)
|
|
|
|
try { |
|
|
|
String join = String.join(",", new ArrayList<>()); |
|
|
|
String customerParameter = java.net.URLEncoder.encode(join, "utf-8"); |
|
|
|
list.forEach(l -> { |
|
|
|
l.setCustomerParameter(customerParameter); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("CustomerFunctionDetailServiceImpl.resiAndWorkFunctionDetail->集合参数URLEncode失败"); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
//2.调用user服务,获取用户角色信息
|
|
|
|
GetRoleKeyListFormDTO dto = new GetRoleKeyListFormDTO(); |
|
|
|
dto.setUserId(formDTO.getUserId()); |
|
|
|
dto.setGridId(formDTO.getGridId()); |
|
|
|
dto.setFromApp(AppClientConstant.APP_RESI); |
|
|
|
Result<List<String>> result = epmetUserOpenFeignClient.getUserRoleKeyList(dto); |
|
|
|
if (!result.success()) { |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
} |
|
|
|
formDTO.setRoleKeyList(result.getData()); |
|
|
|
|
|
|
|
//3.根据用户拥有的角色查询客户的定制功能
|
|
|
|
List<String> listFunctionIds = customerFunctionRoleDao.selectFunctionList(formDTO); |
|
|
|
|
|
|
|
//4.封装结果数据
|
|
|
|
listFunctionIds.forEach(id -> { |
|
|
|
list.forEach(l -> { |
|
|
|
if (id.equals(l.getFunctionId())) { |
|
|
|
restltList.add(l); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return restltList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 根据所属端和客户Id查询客户定制功能列表 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<FunctionDetailResultDTO> workFunctionDetail(FunctionDetailFromDTO formDTO) { |
|
|
|
List<FunctionDetailResultDTO> restltList = new LinkedList<>(); |
|
|
|
//1.根据客户Id和所属端查询客户定制功能列表数据
|
|
|
|
logger.info(String.format("根据客户Id和所属端查询客户定制功能列表,对应客户Id->%s,所属端->%s", formDTO.getCustomerId(), formDTO.getClientType())); |
|
|
|
List<FunctionDetailResultDTO> list = baseDao.selectFunctionDetailList(formDTO); |
|
|
|
if (null != list && list.size() > NumConstant.ZERO) { |
|
|
|
//1-1.设置自定义json数据(暂时为空)
|
|
|
|
try { |
|
|
|
String join = String.join(",", new ArrayList<>()); |
|
|
|
String customerParameter = java.net.URLEncoder.encode(join, "utf-8"); |
|
|
@ -147,7 +206,31 @@ public class CustomerFunctionDetailServiceImpl extends BaseServiceImpl<CustomerF |
|
|
|
logger.error("CustomerFunctionDetailServiceImpl.resiAndWorkFunctionDetail->集合参数URLEncode失败"); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); |
|
|
|
} |
|
|
|
return list; |
|
|
|
|
|
|
|
//2.调用user服务,获取用户角色信息
|
|
|
|
GetRoleKeyListFormDTO dto = new GetRoleKeyListFormDTO(); |
|
|
|
dto.setUserId(formDTO.getUserId()); |
|
|
|
dto.setFromApp(AppClientConstant.APP_GOV); |
|
|
|
Result<List<String>> result = epmetUserOpenFeignClient.getUserRoleKeyList(dto); |
|
|
|
if (!result.success()) { |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
} |
|
|
|
formDTO.setRoleKeyList(result.getData()); |
|
|
|
|
|
|
|
//3.根据用户拥有的角色查询客户的定制功能
|
|
|
|
List<String> listFunctionIds = customerFunctionRoleDao.selectFunctionList(formDTO); |
|
|
|
|
|
|
|
//4.封装结果数据
|
|
|
|
listFunctionIds.forEach(id -> { |
|
|
|
list.forEach(l -> { |
|
|
|
if (id.equals(l.getFunctionId())) { |
|
|
|
restltList.add(l); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return restltList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|