diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java index 924dbc5b4b..7e8f5c4325 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java @@ -17,34 +17,35 @@ package com.epmet.controller; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerFootBarDTO; import com.epmet.dto.form.CustomerFootBarFormDTO; import com.epmet.dto.result.CustomerFootBarResultDTO; import com.epmet.entity.CustomerFootBarEntity; import com.epmet.excel.CustomerFootBarExcel; import com.epmet.service.CustomerFootBarService; -import com.epmet.service.impl.CustomerFunctionDetailServiceImpl; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** @@ -127,12 +128,13 @@ public class CustomerFootBarController { // 查询db List footbars = customerFootBarService.listCustomerFootBars(customerId, appType); List barDTOS = new LinkedList<>(); - footbars.forEach(barEntity -> { - CustomerFootBarEntity defaultFootBarEntity = customerFootBarService.getByAppTypeAndBarKeyOfCustomer("default", barEntity.getAppType(), barEntity.getBarKey()); - CustomerFootBarDTO barDTO = new CustomerFootBarDTO(); - BeanUtils.copyProperties(barEntity, barDTO); - barDTO.setDefaultBarName(defaultFootBarEntity.getBarName()); + List defaultFootBarList = customerFootBarService.listCustomerFootBars("default", appType); + Map defaultBarNameMaps = defaultFootBarList.stream().collect(Collectors.toMap(CustomerFootBarEntity::getBarKey, CustomerFootBarEntity::getBarName)); + footbars.forEach(barEntity -> { + String defaultName = defaultBarNameMaps.getOrDefault(barEntity.getBarKey(), StrConstant.EPMETY_STR); + CustomerFootBarDTO barDTO = ConvertUtils.sourceToTarget(barEntity, CustomerFootBarDTO.class); + barDTO.setDefaultBarName(defaultName); barDTOS.add(barDTO); }); @@ -253,4 +255,4 @@ public class CustomerFootBarController { return new Result(); } -} \ No newline at end of file +}