Commit f6f887f5 by zhiwj

Merge branch 'developer' into 'master'

Developer

See merge request !35
parents 525eea58 a6407146
......@@ -123,6 +123,8 @@ public interface ClerkApiService {
ServiceResponse<List<ClerkDTO>> listClerkByStoreInfoId(Integer enterpriseId, Integer storeInfoId, String search);
ServiceResponse<Page<ClerkDTO>> pageClerkByStoreInfoId(Integer enterpriseId, Integer storeInfoId, String search, Integer pageNum, Integer pageSize);
/**
* 店长
* @Title: getHeadClerk

......
......@@ -151,6 +151,11 @@
<artifactId>gic-spark-run-api</artifactId>
<version>${gic-spark-run-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-member-config-api</artifactId>
<version>${gic-member-config-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -43,7 +43,7 @@ public class StoreBusinessTimeServiceImpl implements StoreBusinessTimeService {
TabStoreBusinessTime businessTime = new TabStoreBusinessTime();
businessTime.setStoreBusinessTimeId(storeBusinessTimeDTO.getStoreBusinessTimeId());
if (StringUtils.isNotBlank(storeBusinessTimeDTO.getWeekday())) {
String weekday = Stream.of(storeBusinessTimeDTO.getWeekday().split(GlobalInfo.FLAG_COMMA)).sorted().reduce((x, y) -> x + GlobalInfo.FLAG_COMMA + y).get();
String weekday = Stream.of(storeBusinessTimeDTO.getWeekday().split(GlobalInfo.FLAG_COMMA)).sorted().collect(Collectors.joining(","));
businessTime.setWeekday(weekday);
}
businessTime.setOpenTime(storeBusinessTimeDTO.getOpenTime());
......
......@@ -495,7 +495,7 @@ public class StoreServiceImpl implements StoreService {
public String listStoreInfoIdByStoreIds(String storeIds, Integer enterpriseId) {
List<Integer> list = Stream.of(storeIds.split(GlobalInfo.FLAG_COMMA)).map(Integer::valueOf).collect(Collectors.toList());
List<Integer> ids = tabStoreMapper.listStoreInfoIdByStoreIds(list, enterpriseId);
return Optional.ofNullable(ids).orElse(Collections.emptyList()).stream().map(String::valueOf).reduce((x,y)-> x + GlobalInfo.FLAG_COMMA + y).orElse("");
return Optional.ofNullable(ids).orElse(Collections.emptyList()).stream().map(String::valueOf).collect(Collectors.joining(","));
}
@Override
......
......@@ -3,23 +3,19 @@ package com.gic.store.service.outer.impl;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.CollectionUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.*;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.dto.wm.WmStoreSyncLogDTO;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.enterprise.service.WmStoreSyncLogApiService;
import com.gic.member.config.api.dto.UserOwnerDefaultDTO;
import com.gic.member.config.api.service.CardAscriptionConfigService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.ClerkLogReasonEnum;
import com.gic.store.constant.ImportClerkBatchResultEnum;
import com.gic.store.constant.StoreLogTypeEnum;
import com.gic.store.constant.StoreOwnTypeEnum;
import com.gic.store.constant.*;
import com.gic.store.dto.*;
import com.gic.store.dto.clerk.OrderAddClerkDTO;
import com.gic.store.dto.clerk.PosAddClerkDTO;
......@@ -29,6 +25,7 @@ import com.gic.store.entity.TabStoreRegion;
import com.gic.store.service.*;
import com.gic.weimob.api.dto.WeimobGuiderSynDTO;
import com.gic.weimob.api.service.WeimobStoreSiteService;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -73,6 +70,8 @@ public class ClerkApiServiceImpl implements ClerkApiService {
private ClerkPositionService clerkPositionService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Autowired
private CardAscriptionConfigService cardAscriptionConfigService;
@Override
public ServiceResponse saveOrUpdate(ClerkDTO clerkDTO) {
......@@ -424,8 +423,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeSearchDBDTO.setStoreInfoIdList(storeInfoIdsBySearch);
storeSearchDBDTO.setSearch(search);
List<StoreDTO> dtos = storeService.listStore(storeSearchDBDTO, 1, Integer.MAX_VALUE);
return Optional.ofNullable(dtos).orElse(Collections.emptyList()).stream().map(e -> e.getStoreId().toString())
.reduce((x, y) -> x + " " + y).orElse("");
return Optional.ofNullable(dtos).orElse(Collections.emptyList()).stream().map(e -> e.getStoreId().toString()).collect(Collectors.joining(" "));
}
......@@ -454,9 +452,24 @@ public class ClerkApiServiceImpl implements ClerkApiService {
String[] split = clerkIds.split(GlobalInfo.FLAG_COMMA);
clerkIdList = Stream.of(split).map(Integer::parseInt).collect(Collectors.toList());
}
Integer i = clerkService.updateClerkStatus(enterpriseId, clerkIdList, status);
for (Integer clerkId : clerkIdList) {
sparkJobApiService.updateClerkStatus(enterpriseId, clerkId.longValue(), 1 == status ? 0 : 1);
if(StoreStatusEnum.INONLINE.getCode() == status){
List<UserOwnerDefaultDTO> result = this.cardAscriptionConfigService.getDefaultUserOwner(enterpriseId).getResult();
if(CollectionUtils.isNotEmpty(result)){
clerkIdList = clerkIdList.stream().filter(clerkId -> {
for(UserOwnerDefaultDTO dto : result){
if(clerkId.intValue() == dto.getClerkId().intValue()){
return false;
}
}
return true;
}).collect(Collectors.toList());
}
}
if(CollectionUtils.isNotEmpty(clerkIdList)){
Integer i = clerkService.updateClerkStatus(enterpriseId, clerkIdList, status);
for (Integer clerkId : clerkIdList) {
sparkJobApiService.updateClerkStatus(enterpriseId, clerkId.longValue(), 1 == status ? 0 : 1);
}
}
}
......@@ -491,6 +504,15 @@ public class ClerkApiServiceImpl implements ClerkApiService {
}
@Override
public ServiceResponse<Page<ClerkDTO>> pageClerkByStoreInfoId(Integer enterpriseId, Integer storeInfoId, String search, Integer pageNum, Integer pageSize) {
List<Integer> storeInfoIds = new ArrayList<>();
storeInfoIds.add(storeInfoId);
PageHelper.startPage(pageNum, pageSize);
List<TabClerk> clerkList = this.clerkService.listClerkByStoreInfoId(enterpriseId, storeInfoIds, search);
return ServiceResponse.success(PageHelperUtils.changePageHelperToCurrentPage(clerkList, ClerkDTO.class));
}
@Override
public ServiceResponse<ClerkDTO> getHeadClerk(Integer enterpriseId, Integer storeId) {
ServiceResponse<StoreDTO> response = storeApiService.getStoreById(enterpriseId, storeId);
if (response.isSuccess() && response.getResult() != null) {
......@@ -678,7 +700,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
return EnterpriseServiceResponse.failure(ErrorCode.NOTEXISTS);
}
// list 如果太大, 让 mybatis 解析 会打满内存
String storeInfoIds = list.stream().map(e -> e.getStoreInfoId().toString()).reduce((x, y) -> x + "," + y).get();
String storeInfoIds = list.stream().map(e -> e.getStoreInfoId().toString()).collect(Collectors.joining(","));
storeInfoIds = "(" + storeInfoIds + ")";
List<TabClerk> clerkList = this.clerkService.listClerkByStoreInfoId(enterpriseId, storeInfoIds, clerkName);
List<ClerkDTO> dtoList = EntityUtil.changeEntityListByJSON(ClerkDTO.class, clerkList);
......
......@@ -426,15 +426,14 @@ public class StoreApiServiceImpl implements StoreApiService {
this.storeBusinessTimeService.convertBusinessTime(newStore.getBusinessTimeList());
String newBusinessTimeShow = newStore.getBusinessTimeList().stream()
.map(e -> e.getWeekdayShow() + ":" + DateUtil.dateToStr(e.getOpenTime(), DateUtil.FORMAT_MINUTE_TIME) + "~" + DateUtil.dateToStr(e.getCloseTime(), DateUtil.FORMAT_MINUTE_TIME))
.reduce((x, y) -> x + "," + y)
.orElse("");
.collect(Collectors.joining(","));
sb.append("营业时间").append("变更为【").append(newBusinessTimeShow).append("】");
}
}
}
if (StringUtils.isNotBlank(newStore.getBrandIds()) && !StringUtils.equals(newStore.getBrandIds(), oldStore.getBrandIds())) {
List<TabStoreBrand> tabStoreBrands = this.storeBrandService.listStoreBrandByIds(newStore.getBrandIds());
String storeBrandShow = tabStoreBrands.stream().map(TabStoreBrand::getStoreBrandName).reduce((x, y) -> x + "," + y).orElse("");
String storeBrandShow = tabStoreBrands.stream().map(TabStoreBrand::getStoreBrandName).collect(Collectors.joining(","));;
sb.append("门店品牌").append("变更为【").append(storeBrandShow).append("】");
}
if (StringUtils.isNotBlank(newStore.getAddress()) && !StringUtils.equals(newStore.getAddress(), oldStore.getAddress())) {
......
......@@ -106,7 +106,7 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
if (CollectionUtils.isEmpty(storeBrandList)) {
return ServiceResponse.success();
}
String ids = storeBrandList.stream().map(e -> e.getStoreBrandId().toString()).reduce((x, y) -> x + GlobalInfo.FLAG_COMMA + y).get();
String ids = storeBrandList.stream().map(e -> e.getStoreBrandId().toString()).collect(Collectors.joining(","));
return this.deleteByIds(enterpriseId, ids);
}
......
......@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author zhiwj
......@@ -283,7 +284,7 @@ public class StoreTaskServiceImpl extends AbstractTaskAllocationOperation implem
return false;
})
.map(e -> e.getStoreFieldSelectId() + "")
.reduce((x, y) -> x + GlobalInfo.FLAG_COMMA + y).get();
.collect(Collectors.joining(","));
storeExtendDTO.setValue(newValue);
}
}
......
package com.gic.store.strategy.impl;
import com.gic.member.config.api.dto.UserOwnerDefaultDTO;
import com.gic.member.config.api.service.CardAscriptionConfigService;
import com.gic.spark.api.service.SparkJobApiService;
import com.gic.store.constant.StoreStatusEnum;
import com.gic.store.service.StoreLogService;
import com.gic.store.service.StoreService;
import com.gic.store.strategy.BulkUpdateStoreStrtegy;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
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;
@Component("1")
public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
......@@ -18,29 +24,46 @@ public class StoreStatusStrategyImpl implements BulkUpdateStoreStrtegy {
private StoreLogService storeLogService;
@Autowired
private SparkJobApiService sparkJobApiService;
@Autowired
private CardAscriptionConfigService cardAscriptionConfigService;
@Override
public int bulkUpdateStore(String storeInfoIds, Integer enterpriseId, String value, StoreService storeService, Integer operatorId, String operatorName) {
int i = storeService.bulkUpdateStoreStatus(storeInfoIds, enterpriseId, value);
if (i > 0) {
List<Integer> storeInfoIdList;
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeInfoIdList.add(Integer.valueOf(s));
}
List<Integer> storeInfoIdList = new ArrayList<>();
List<UserOwnerDefaultDTO> result = this.cardAscriptionConfigService.getDefaultUserOwner(enterpriseId).getResult();
if ("all".equals(storeInfoIds)) {
storeInfoIdList = storeService.listAllStoreInfoId(enterpriseId);
} else {
storeInfoIdList = new ArrayList<>();
String[] storeIdArr = storeInfoIds.split(",");
for (String s : storeIdArr) {
storeInfoIdList.add(Integer.valueOf(s));
}
int valueCode = Integer.parseInt(value);
storeLogService.saveBulkStoreStatusLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店状态变更为【" + StoreStatusEnum.parseCode(valueCode) + "】");
}
if(CollectionUtils.isNotEmpty(result) && StoreStatusEnum.INONLINE.getCode() == Integer.valueOf(value)){
storeInfoIdList = storeInfoIdList.stream().filter(storeInfoId -> {
for(UserOwnerDefaultDTO dto : result){
if(storeInfoId.intValue() == dto.getStoreInfoId().intValue()){
return false;
}
}
return true;
}).collect(Collectors.toList());
}
if(CollectionUtils.isNotEmpty(storeInfoIdList)){
String storeInfoIdsNew = StringUtils.join(storeInfoIdList, ",");
int i = storeService.bulkUpdateStoreStatus(storeInfoIdsNew, enterpriseId, value);
if (i > 0) {
int valueCode = Integer.parseInt(value);
storeLogService.saveBulkStoreStatusLog(storeInfoIdList, enterpriseId, operatorId, operatorName, "门店状态变更为【" + StoreStatusEnum.parseCode(valueCode) + "】");
for (Integer storeInfoId : storeInfoIdList) {
// 启用禁用的值和会员组取的不一致 需要转换下
sparkJobApiService.updateStoreStatus(enterpriseId, storeInfoId, StoreStatusEnum.ONLINE.getCode() == valueCode ? 0 : 1);
for (Integer storeInfoId : storeInfoIdList) {
// 启用禁用的值和会员组取的不一致 需要转换下
sparkJobApiService.updateStoreStatus(enterpriseId, storeInfoId, StoreStatusEnum.ONLINE.getCode() == valueCode ? 0 : 1);
}
}
return i;
}
return i;
return 0;
}
}
......@@ -69,4 +69,5 @@
<dubbo:reference interface="com.gic.weimob.api.service.WeimobStoreSiteService" id="weimobStoreSiteService" timeout="6000"/>
<dubbo:reference interface="com.gic.enterprise.service.WmStoreSyncLogApiService" id="wmStoreSyncLogApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.spark.api.service.SparkJobApiService" id="sparkJobApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.member.config.api.service.CardAscriptionConfigService" id="cardAscriptionConfigService" timeout="6000"/>
</beans>
......@@ -95,8 +95,7 @@ public class StoreBrandController {
.orElse(Collections.emptyList())
.stream()
.map(StoreBrandDTO::getStoreBrandName)
.reduce((x, y) -> x + "," + y)
.orElse("");
.collect(Collectors.joining(","));
LogUtils.createLog("删除门店品牌", logName);
}
return RestResponse.success(serviceResponse.getResult());
......
......@@ -393,7 +393,7 @@ public class StoreController extends DownloadUtils {
if (page != null && CollectionUtils.isNotEmpty(page.getResult())) {
List<StoreDTO> storeList = page.getResult();
if (CollectionUtils.isNotEmpty(storeList)) {
String storeName = storeList.stream().map(StoreDTO::getStoreName).reduce((x, y) -> x + "," + y).get();
String storeName = storeList.stream().map(StoreDTO::getStoreName).collect(Collectors.joining(","));
if (storeArr.length > 3) {
storeName += "等" + storeArr.length + "家门店";
}
......
......@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zhiwj
......@@ -539,7 +540,7 @@ public class StoreImportController {
if (response.isSuccess()) {
List<String> brandList = response.getResult();
if (CollectionUtils.isNotEmpty(brandList)) {
String error = brandList.stream().reduce((x, y) -> x + " " + y).get();
String error = brandList.stream().collect(Collectors.joining(","));
return "品牌 " + error + " 不存在";
}
return null;
......
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