|
@@ -12,6 +12,7 @@ import com.zcxk.core.mysql.pageing.Pagination;
|
|
|
import com.zcxk.core.oauth2.pojo.LoginUser;
|
|
|
import com.zcxk.core.oauth2.util.UserUtil;
|
|
|
import com.zcxk.core.utils.BigDecimalUtils;
|
|
|
+import com.zcxk.core.utils.CollectionsUtils;
|
|
|
import com.zcxk.core.utils.ZoniotIntegerUtils;
|
|
|
import com.zcxk.core.utils.export.EasyExcelUtil;
|
|
|
import com.zcxk.rmcp.api.dto.device.DeviceInputDto;
|
|
@@ -27,6 +28,7 @@ import com.zcxk.rmcp.core.entity.Org;
|
|
|
import com.zcxk.rmcp.core.entity.Product;
|
|
|
import com.zcxk.rmcp.web.excel.download.adapter.DeviceExcelFillAdapter;
|
|
|
import com.zcxk.rmcp.web.excel.download.service.DeviceDownloadExcelService;
|
|
|
+import com.zcxk.rmcp.web.excel.model.CommImportData;
|
|
|
import com.zcxk.rmcp.web.excel.model.DeviceImportData;
|
|
|
import com.zcxk.rmcp.web.excel.model.DownloadExcelData;
|
|
|
import com.zcxk.rmcp.web.excel.model.ExcelData;
|
|
@@ -43,10 +45,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -238,13 +237,148 @@ public class DeviceServiceImpl implements DeviceService{
|
|
|
@Override
|
|
|
public DeviceMapDataVo listDeviceAndCommunityInfo(Integer categoryId){
|
|
|
UserCondition condition = UserUtil.getCurrentUser().getUserCondition();
|
|
|
+ List<DeviceCategoryCommunityVo> communityVos = deviceMapper.listCommunityDevice(categoryId, condition);
|
|
|
DeviceMapDataVo result = new DeviceMapDataVo();
|
|
|
- result.setDeviceCommunityList(deviceMapper.listCommunityDevice(categoryId, condition));
|
|
|
+ // 分类
|
|
|
+ Map<Long, ProductCategoryCommunityVo> productCategoryCommunityVoMap = new HashMap<>();
|
|
|
+ // 小区
|
|
|
+ Map<Long, CommunityProductCategoryVo> communityProductCategoryVoHashMap = new HashMap<>();
|
|
|
+ for (DeviceCategoryCommunityVo communityVo : communityVos) {
|
|
|
+ if (communityVo.getCategoryId() != null) {
|
|
|
+ mergeCategoryCommunity(productCategoryCommunityVoMap, communityVo);
|
|
|
+ }
|
|
|
+ mergeCommunityCategory(communityProductCategoryVoHashMap, communityVo);
|
|
|
+ }
|
|
|
+ result.setCategoryCommunityVos(CollectionsUtils.mapToList(productCategoryCommunityVoMap));
|
|
|
+ result.setCommunityCategoryVos(CollectionsUtils.mapToList(communityProductCategoryVoHashMap));
|
|
|
result.setNoCellVoList(deviceMapper.listNoCellDevice(categoryId, condition));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * @author Andy
|
|
|
+ * @description 合并相同的小区数据
|
|
|
+ * @date 14:05 2021/7/30
|
|
|
+ * @param communityProductCategoryVoHashMap, communityVo]
|
|
|
+ * @return void
|
|
|
+ **/
|
|
|
+ private void mergeCommunityCategory(Map<Long, CommunityProductCategoryVo> communityProductCategoryVoHashMap, DeviceCategoryCommunityVo communityVo){
|
|
|
+ CommunityProductCategoryVo communityProductCategoryVo = communityProductCategoryVoHashMap.get(communityVo.getCommunityId());
|
|
|
+ if (communityProductCategoryVo == null) {
|
|
|
+ communityProductCategoryVo = new CommunityProductCategoryVo();
|
|
|
+ BeanCopyUtils.copyProperties(communityVo, communityProductCategoryVo, CommunityProductCategoryVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找分类
|
|
|
+ List<ProductCategoryStatusVo> deviceCommunityVos = communityProductCategoryVo.getCategoryStatusVos();
|
|
|
+ if (CollectionUtils.isEmpty(deviceCommunityVos)) {
|
|
|
+ deviceCommunityVos = new ArrayList<>();
|
|
|
+ }
|
|
|
+ ProductCategoryStatusVo deviceCommunityVo = findProductCategory(communityVo.getCategoryId(), deviceCommunityVos);
|
|
|
+ boolean isEmpty = false;
|
|
|
+ if (deviceCommunityVo == null) {
|
|
|
+ deviceCommunityVo = new ProductCategoryStatusVo();
|
|
|
+ BeanCopyUtils.copyProperties(communityVo, deviceCommunityVo, ProductCategoryStatusVo.class);
|
|
|
+ isEmpty = true;
|
|
|
+ }
|
|
|
+ List<StatusStatisticsVo> statusStatisticsVos = deviceCommunityVo.getStatusVos();
|
|
|
+ if (statusStatisticsVos == null) {
|
|
|
+ statusStatisticsVos = new ArrayList<>();
|
|
|
+ deviceCommunityVo.setStatusVos(statusStatisticsVos);
|
|
|
+ }
|
|
|
+ setStatusStatisticsVos(statusStatisticsVos,communityVo);
|
|
|
+ if (isEmpty) {
|
|
|
+ deviceCommunityVos.add(deviceCommunityVo);
|
|
|
+ communityProductCategoryVo.setCategoryStatusVos(deviceCommunityVos);
|
|
|
+ }
|
|
|
+ communityProductCategoryVoHashMap.put(communityVo.getCommunityId(), communityProductCategoryVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author Andy
|
|
|
+ * @description 合并相同的分类数据
|
|
|
+ * @date 14:05 2021/7/30
|
|
|
+ * @param productCategoryCommunityVoMap, communityVo
|
|
|
+ * @return void
|
|
|
+ **/
|
|
|
+ private void mergeCategoryCommunity(Map<Long, ProductCategoryCommunityVo> productCategoryCommunityVoMap, DeviceCategoryCommunityVo communityVo){
|
|
|
+ ProductCategoryCommunityVo productCategoryCommunityVo = productCategoryCommunityVoMap.get(communityVo.getCategoryId());
|
|
|
+ if (productCategoryCommunityVo == null) {
|
|
|
+ productCategoryCommunityVo = new ProductCategoryCommunityVo();
|
|
|
+ productCategoryCommunityVo.setCategoryId(communityVo.getCategoryId());
|
|
|
+ productCategoryCommunityVo.setCategoryName(communityVo.getCategoryName());
|
|
|
+ }
|
|
|
+ // 查找小区
|
|
|
+ List<DeviceCommunityVo> deviceCommunityVos = productCategoryCommunityVo.getCommunityVos();
|
|
|
+ if (CollectionUtils.isEmpty(deviceCommunityVos)) {
|
|
|
+ deviceCommunityVos = new ArrayList<>();
|
|
|
+ }
|
|
|
+ DeviceCommunityVo deviceCommunityVo = findCommunity(communityVo.getCommunityId(), deviceCommunityVos);
|
|
|
+ boolean isEmpty = false;
|
|
|
+ if (deviceCommunityVo == null) {
|
|
|
+ deviceCommunityVo = new DeviceCommunityVo();
|
|
|
+ BeanCopyUtils.copyProperties(communityVo, deviceCommunityVo, DeviceCommunityVo.class);
|
|
|
+ isEmpty = true;
|
|
|
+ }
|
|
|
+ List<StatusStatisticsVo> statusStatisticsVos = deviceCommunityVo.getStatusVos();
|
|
|
+ if (statusStatisticsVos == null) {
|
|
|
+ statusStatisticsVos = new ArrayList<>();
|
|
|
+ deviceCommunityVo.setStatusVos(statusStatisticsVos);
|
|
|
+ }
|
|
|
+ setStatusStatisticsVos(statusStatisticsVos, communityVo);
|
|
|
+ if (isEmpty) {
|
|
|
+ deviceCommunityVos.add(deviceCommunityVo);
|
|
|
+ productCategoryCommunityVo.setCommunityVos(deviceCommunityVos);
|
|
|
+ }
|
|
|
+ productCategoryCommunityVoMap.put(communityVo.getCategoryId(), productCategoryCommunityVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author Andy
|
|
|
+ * @description 设置状态数据
|
|
|
+ * @date 14:06 2021/7/30
|
|
|
+ * @param statusStatisticsVos, communityVo
|
|
|
+ * @return void
|
|
|
+ **/
|
|
|
+ private void setStatusStatisticsVos(List<StatusStatisticsVo> statusStatisticsVos, DeviceCategoryCommunityVo communityVo){
|
|
|
+ StatusStatisticsVo statusStatisticsVo = new StatusStatisticsVo();
|
|
|
+ BeanCopyUtils.copyProperties(communityVo, statusStatisticsVo, StatusStatisticsVo.class);
|
|
|
+ statusStatisticsVos.add(statusStatisticsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author Andy
|
|
|
+ * @description 查找小区
|
|
|
+ * @date 14:06 2021/7/30
|
|
|
+ * @param communityId, list
|
|
|
+ * @return com.zcxk.rmcp.api.vo.DeviceCommunityVo
|
|
|
+ **/
|
|
|
+ private DeviceCommunityVo findCommunity(Long communityId, List<DeviceCommunityVo> list){
|
|
|
+ for (DeviceCommunityVo deviceCommunityVo : list) {
|
|
|
+ if (deviceCommunityVo.getCommunityId() == communityId) {
|
|
|
+ return deviceCommunityVo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author Andy
|
|
|
+ * @description 查找分类
|
|
|
+ * @date 14:06 2021/7/30
|
|
|
+ * @param categoryId, list
|
|
|
+ * @return com.zcxk.rmcp.api.vo.ProductCategoryStatusVo
|
|
|
+ **/
|
|
|
+ private ProductCategoryStatusVo findProductCategory(Long categoryId, List<ProductCategoryStatusVo> list){
|
|
|
+ for (ProductCategoryStatusVo productCategoryStatusVo : list) {
|
|
|
+ if (productCategoryStatusVo.getCategoryId() == categoryId) {
|
|
|
+ return productCategoryStatusVo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @author Andy
|
|
|
* @description 统计状态数
|