Commit ec5e1e79 by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-data-cloud into developer
parents 042fb5b7 a7cb5970
......@@ -3,6 +3,7 @@ package com.gic.cloud.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.FunctionDTO;
import com.gic.cloud.dto.FunctionModuleDTO;
import java.util.List;
......@@ -26,4 +27,6 @@ public interface FunctionApiService {
ServiceResponse<List<FunctionDTO>> listFunction(Integer enterpriseId, String functionName);
ServiceResponse<FunctionDTO> getFunction(Integer functionId);
ServiceResponse<List<FunctionModuleDTO>> getFunctionByUserId(Integer userId);
}
......@@ -4,9 +4,13 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.constants.FunctionEnum;
import com.gic.cloud.dto.FunctionDTO;
import com.gic.cloud.dto.FunctionModuleDTO;
import com.gic.cloud.dto.UserDTO;
import com.gic.cloud.entity.TabSysFunction;
import com.gic.cloud.entity.TabSysFunctionModule;
import com.gic.cloud.entity.TabSysUser;
import com.gic.cloud.service.FunctionApiService;
import com.gic.cloud.service.FunctionModuleService;
import com.gic.cloud.service.FunctionService;
import com.gic.cloud.service.UserService;
import com.gic.commons.util.EntityUtil;
......@@ -27,6 +31,8 @@ public class FunctionApiServiceImpl implements FunctionApiService{
private FunctionService functionService;
@Autowired
private UserService userService;
@Autowired
private FunctionModuleService functionModuleService;
@Override
public ServiceResponse<Integer> saveFunction(FunctionDTO dto) {
......@@ -90,6 +96,26 @@ public class FunctionApiServiceImpl implements FunctionApiService{
return ServiceResponse.success(EntityUtil.changeEntityNew(FunctionDTO.class, functionService.getFunction(functionId)));
}
@Override
public ServiceResponse<List<FunctionModuleDTO>> getFunctionByUserId(Integer userId) {
TabSysUser user = userService.getUser(userId);
if (user == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户不存在");
}
TabSysFunction record = functionService.getFunction(user.getFunctionAuthId());
if (record != null) {
List<TabSysFunctionModule> moduleList = functionModuleService.listFunctionModule(null);
Map<String, TabSysFunctionModule> map = moduleList.stream().collect(Collectors.toMap(e -> e.getFunctionModuleCode(), e -> e));
return ServiceResponse.success(Arrays.stream(record.getFunctionComponent()
.split("_"))
.filter(e -> StringUtils.isNotBlank(e))
.map(e -> EntityUtil.changeEntityNew(FunctionModuleDTO.class, map.get(e)))
.collect(Collectors.toList()));
}
return ServiceResponse.success(Collections.emptyList());
}
private ServiceResponse<Void> validParam(FunctionDTO dto) {
if (dto.getFunctionId() != null) {
TabSysFunction record = functionService.getFunction(dto.getFunctionId());
......
......@@ -6,10 +6,15 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.DataAuthDTO;
import com.gic.cloud.service.DataAuthApiService;
import com.gic.cloud.web.vo.MbrVo;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.member.config.api.dto.OwnerMemberCardDTO;
import com.gic.member.config.api.service.MemberCardApiService;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.service.StoreApiService;
import com.gic.store.service.StoreWidgetApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -17,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
......@@ -30,6 +36,8 @@ public class DataAuthUtils {
private StoreWidgetApiService storeWidgetApiService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private MemberCardApiService memberCardApiService;
public StoreAuth getStoreAuth(Integer userId, Integer enterpriseId){
ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId);
......@@ -77,4 +85,21 @@ public class DataAuthUtils {
}
public List<MbrVo> getMbrArea(Integer userId, Integer enterpriseId){
ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId);
if(response.isSuccess() && response.getResult() != null){
ServiceResponse<List<OwnerMemberCardDTO>> result = memberCardApiService.getAll(enterpriseId);
List<String> cards = Arrays.asList(response.getResult().getMemberCardAuth().split("_"));
if(result.isSuccess() && CollectionUtils.isNotEmpty(result.getResult())){
return result.getResult().stream().filter(dto ->cards.contains(dto.getId()+"")).map(ownerMemberCardDTO -> {
MbrVo vo = new MbrVo();
vo.setMbrAreaId(ownerMemberCardDTO.getId().toString());
vo.setMbrAreaName(ownerMemberCardDTO.getCardName());
return vo;
}).collect(Collectors.toList());
}
}
return new ArrayList<>();
}
}
package com.gic.cloud.web.controller;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.service.IndexApiService;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.qo.DateTypeQo;
import com.gic.cloud.web.vo.MbrVo;
import com.gic.cloud.web.vo.index.IndexSalesVo;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.dto.IndexSalesDTO;
import com.gic.data.api.service.IndexSalesApiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class IndexController {
@Autowired
private IndexSalesApiService indexSalesApiService;
@Autowired
private StoreSearchUtils storeSearchUtils;
@Autowired
private DataAuthUtils dataAuthUtils;
@RequestMapping("index-mbr")
public RestResponse indexMbr(Integer enterpriseId, Integer userId){
List<MbrVo> mbrArea = this.dataAuthUtils.getMbrArea(userId, enterpriseId);
return RestResponse.success(mbrArea);
}
@RequestMapping("index-sales")
public RestResponse indexSales(Integer userId, Integer enterpriseId, String searchJSON,
DateTypeQo dateTypeQo, String mbrAreaId, Integer dataType){
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
ServiceResponse<IndexSalesDTO> indexSales = this.indexSalesApiService.getIndexSales(enterpriseId, list, onLine,
StringUtils.isNoneBlank(mbrAreaId) ? Long.valueOf(mbrAreaId) : null, dateTypeQo.getType(), dateTypeQo.getDate(), dataType);
return RestResponse.success(EntityUtil.changeEntityByJSON(IndexSalesVo.class, indexSales.getResult()));
}
}
package com.gic.cloud.web.controller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.qo.performanceoverview.PerformanceOverviewQO;
import com.gic.data.api.service.performanceoverview.PerformanceOverviewApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
@RestController
public class PerformanceOverviewController {
private static final Logger log = LogManager.getLogger(PerformanceOverviewController.class);
@Autowired
private PerformanceOverviewApiService performanceOverviewApiService;
@Autowired
private StoreSearchUtils storeSearchUtils;
@RequestMapping("get-performance-overview")
public RestResponse selectPerformanceOverview(PerformanceOverviewQO params) {
log.info("业绩概览参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
return ResultControllerUtils.commonResult(performanceOverviewApiService.selectPerformanceOverview(params));
}
}
......@@ -146,20 +146,31 @@ public class StoreSearchUtils {
}
}
public List<Integer> getChildrenStoreGroupIdList(Integer storeGroupId){
List<StoreGroupDTO> result = this.storeGroupApiService.listStoreGroupAndChildren(storeGroupId).getResult();
if(CollectionUtils.isNotEmpty(result)){
return result.stream().map(storeGroupDTO -> storeGroupDTO.getStoreGroupId()).collect(Collectors.toList());
}else {
return new ArrayList<>();
}
}
private void getOnlineStoreIds(String searchJson, OnLineAuth onlineStoreAuth, List<String> list, Integer channel){
StoreSearchQo searchQo = JSON.parseObject(searchJson).getObject(channel.toString(), StoreSearchQo.class);
log.info("getOnlineStoreIds:{},{}", searchJson, JSON.toJSONString(searchQo));
if(searchQo != null){
if(searchQo.getAll() == 1){
onlineStoreAuth.getList().stream().filter(s -> {
if(s.getChannel() == channel){
list.addAll(s.getStoreIdList());
if(StringUtils.isNotBlank(searchJson)){
StoreSearchQo searchQo = JSON.parseObject(searchJson).getObject(channel.toString(), StoreSearchQo.class);
log.info("getOnlineStoreIds:{},{}", searchJson, JSON.toJSONString(searchQo));
if(searchQo != null){
if(searchQo.getAll() == 1){
onlineStoreAuth.getList().stream().filter(s -> {
if(s.getChannel() == channel){
list.addAll(s.getStoreIdList());
}
return false;
});
}else {
if(StringUtils.isNotBlank(searchQo.getStoreGroupIds())){
list.addAll(Arrays.asList(searchQo.getStoreGroupIds().split(",")));
}
return false;
});
}else {
if(StringUtils.isNotBlank(searchQo.getStoreGroupIds())){
list.addAll(Arrays.asList(searchQo.getStoreGroupIds().split(",")));
}
}
}
......
package com.gic.cloud.web.vo;
public class MbrVo {
private String mbrAreaId;
private String mbrAreaName;
public String getMbrAreaId() {
return mbrAreaId;
}
public void setMbrAreaId(String mbrAreaId) {
this.mbrAreaId = mbrAreaId;
}
public String getMbrAreaName() {
return mbrAreaName;
}
public void setMbrAreaName(String mbrAreaName) {
this.mbrAreaName = mbrAreaName;
}
}
package com.gic.cloud.web.vo.index;
public class IndexConsume {
private String memberRate;
private String oldRate;
private String birthRate;
private String memberHb;
private String oldHb;
private String birthHb;
public String getMemberRate() {
return memberRate;
}
public void setMemberRate(String memberRate) {
this.memberRate = memberRate;
}
public String getOldRate() {
return oldRate;
}
public void setOldRate(String oldRate) {
this.oldRate = oldRate;
}
public String getBirthRate() {
return birthRate;
}
public void setBirthRate(String birthRate) {
this.birthRate = birthRate;
}
public String getMemberHb() {
return memberHb;
}
public void setMemberHb(String memberHb) {
this.memberHb = memberHb;
}
public String getOldHb() {
return oldHb;
}
public void setOldHb(String oldHb) {
this.oldHb = oldHb;
}
public String getBirthHb() {
return birthHb;
}
public void setBirthHb(String birthHb) {
this.birthHb = birthHb;
}
}
package com.gic.cloud.web.vo.index;
public class IndexMemberVo {
private String newMember;
private String totalMember;
private String posMember;
private String szMember;
private String tb;
private String hb;
public String getNewMember() {
return newMember;
}
public void setNewMember(String newMember) {
this.newMember = newMember;
}
public String getTotalMember() {
return totalMember;
}
public void setTotalMember(String totalMember) {
this.totalMember = totalMember;
}
public String getPosMember() {
return posMember;
}
public void setPosMember(String posMember) {
this.posMember = posMember;
}
public String getSzMember() {
return szMember;
}
public void setSzMember(String szMember) {
this.szMember = szMember;
}
public String getTb() {
return tb;
}
public void setTb(String tb) {
this.tb = tb;
}
public String getHb() {
return hb;
}
public void setHb(String hb) {
this.hb = hb;
}
}
package com.gic.cloud.web.vo.index;
public class IndexSalesVo {
private String totalSales;
private String perf;
private String tb;
private String hb;
private String scrAch;
private String tolAch;
public String getTotalSales() {
return totalSales;
}
public void setTotalSales(String totalSales) {
this.totalSales = totalSales;
}
public String getPerf() {
return perf;
}
public void setPerf(String perf) {
this.perf = perf;
}
public String getTb() {
return tb;
}
public void setTb(String tb) {
this.tb = tb;
}
public String getHb() {
return hb;
}
public void setHb(String hb) {
this.hb = hb;
}
public String getScrAch() {
return scrAch;
}
public void setScrAch(String scrAch) {
this.scrAch = scrAch;
}
public String getTolAch() {
return tolAch;
}
public void setTolAch(String tolAch) {
this.tolAch = tolAch;
}
}
......@@ -9,10 +9,10 @@
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.enterprise"/>
<context:component-scan base-package="com.gic.cloud"/>
<!-- 应用名称 -->
<dubbo:application name="gic-platform-enterprise-web"/>
<dubbo:application name="gic-data-cloud-wxapp"/>
<dubbo:reference interface="com.gic.store.service.StoreRegionApiService" id="storeRegionApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreBrandApiService" id="storeBrandApiService" timeout="60000" retries="0"/>
......@@ -145,4 +145,7 @@
<dubbo:reference interface="com.gic.cloud.service.TempStoreConditionApiService" id="tempStoreConditionApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.IndexDescApiService" id="indexDescApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.DataExplainApiService" id="dataExplainApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.data.api.service.IndexSalesApiService" id="indexSalesApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.data.api.service.performanceoverview.PerformanceOverviewApiService" id="performanceOverviewApiService" timeout="6000" retries="0"/>
</beans>
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