linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java
@@ -116,7 +116,7 @@
      List<HouseholdVO> householdVOS = baseMapper.selectHouseholdPage(page, household, commonParamSet.getIsAdministrator(),
         commonParamSet.getRegionChildCodesList(), commonParamSet.getGridCodeList());
      stopWatch.stop();
      if (household.getRelationship() == 18) {
      if (household.getRelationship() != null && household.getRelationship() == 18) {
         householdVOS.forEach(item -> {
            HouseholdEntity householdEntity = getOne(Wrappers.<HouseholdEntity>lambdaQuery()
               .eq(HouseholdEntity::getHouseCode, item.getHouseCode())
@@ -455,28 +455,29 @@
            }
         }
         // 判断是否租户导入
         if (StringUtils.isNotBlank(isTenant)) {
            householdEntity.setRelationship(18);
            HouseRentalEntity houseRentalEntity = iHouseRentalService.getOne(Wrappers.<HouseRentalEntity>lambdaQuery()
               .eq(HouseRentalEntity::getHouseCode, householdEntity.getHouseCode()).last("limit 1"));
            if (houseRentalEntity != null) {
               householdEntity.setHousingRentalId(houseRentalEntity.getId());
            } else {
               // 新建出租屋
               HouseRentalEntity rentalEntity = new HouseRentalEntity();
               rentalEntity.setHouseCode(householdEntity.getHouseCode());
               rentalEntity.setHouseStatus(1);
               rentalEntity.setAuditStatus(0);
               rentalEntity.setRentalUse(4);
               rentalEntity.setTenantRelationship(1);
               rentalEntity.setRentalTime(new Date());
               rentalEntity.setDueTime(new Date());
               rentalEntity.setTerminationTime(new Date());
               iHouseRentalService.save(rentalEntity);
               householdEntity.setHousingRentalId(rentalEntity.getId());
            }
      if (StringUtils.isNotBlank(isTenant) || (householdEntity.getRelationship() != null && householdEntity.getRelationship() == 18)) {
         householdEntity.setRelationship(18);
         HouseRentalEntity houseRentalEntity = iHouseRentalService.getOne(Wrappers.<HouseRentalEntity>lambdaQuery()
            .eq(HouseRentalEntity::getHouseCode, householdEntity.getHouseCode()).last("limit 1"));
         if (houseRentalEntity != null) {
            householdEntity.setHousingRentalId(houseRentalEntity.getId());
         } else {
            // 新建出租屋
            HouseRentalEntity rentalEntity = new HouseRentalEntity();
            rentalEntity.setHouseCode(householdEntity.getHouseCode());
            rentalEntity.setHouseStatus(1);
            rentalEntity.setAuditStatus(0);
            rentalEntity.setRentalUse(4);
            rentalEntity.setTenantRelationship(1);
            rentalEntity.setRentalTime(new Date());
            rentalEntity.setDueTime(new Date());
            rentalEntity.setTerminationTime(new Date());
            iHouseRentalService.save(rentalEntity);
            householdEntity.setHousingRentalId(rentalEntity.getId());
         }
         // 设置出租房
         setRentalPropertyLabels(householdEntity);
      }
         /// 是否主要联系人
         if (!Strings.isBlank(houseHoldExcel.getIsPrimaryContact())) {
            householdEntity.setIsPrimaryContact(Integer.parseInt(houseHoldExcel.getIsPrimaryContact()));
@@ -565,6 +566,26 @@
   }
   /**
    * @param householdEntity
    */
   private void setRentalPropertyLabels(HouseholdEntity householdEntity) {
      // 设置房屋标签未出租
      IUserHouseLabelService householdLabelService = SpringUtils.getBean(IUserHouseLabelService.class);
      long count = householdLabelService.count(Wrappers.<UserHouseLabelEntity>lambdaQuery()
         .eq(UserHouseLabelEntity::getHouseCode, householdEntity.getHouseCode())
         .eq(UserHouseLabelEntity::getLableType, 2));
      if (count == 0) {
         UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity();
         userHouseLabelEntity.setHouseCode(householdEntity.getHouseCode());
         userHouseLabelEntity.setLableType(2);
         userHouseLabelEntity.setLabelName("出租");
         userHouseLabelEntity.setLabelId(1039L);
         userHouseLabelEntity.setColor("yellow");
         householdLabelService.saveOrUpdateHouseLabel(userHouseLabelEntity);
      }
   }
   /**
    * 标签处理
    *
    * @param householdEntity
@@ -598,8 +619,8 @@
      HouseholdVO householdVO = new HouseholdVO();
      householdVO.setConfirmFlag(confirmFlag);
      householdVO.setCommunityCode(neiCode);
      householdVO.setUserId(AuthUtil.getUserId());
      CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseholdVO.class, householdVO);
      return baseMapper.statistics(householdVO, commonParamSet.getIsAdministrator(),
         commonParamSet.getRegionChildCodesList(), commonParamSet.getGridCodeList());
   }
@@ -629,15 +650,16 @@
   @Override
   public Object getHouseHoldStatistics(String code, String roleType) {
      Map<String, Object> objectObjectHashMap = new HashMap<>();
      List<String> communityCodeList = Func.toStrList(code);
      if (roleType.equals("2")) {
         List<Map<String, Object>> result = baseMapper.getHouseHoldStatistics(code, null, roleType);
         List<Map<String, Object>> result1 = baseMapper.getHouseHoldStatisticsAge(code, null, roleType);
         List<Map<String, Object>> result = baseMapper.getHouseHoldStatistics(communityCodeList, null, roleType);
         List<Map<String, Object>> result1 = baseMapper.getHouseHoldStatisticsAge(communityCodeList, null, roleType);
         objectObjectHashMap.put("gender", result);
         objectObjectHashMap.put("age", result1);
         return objectObjectHashMap;
      } else {
         List<Map<String, Object>> result = baseMapper.getHouseHoldStatistics(code, AuthUtil.getUserId(), roleType);
         List<Map<String, Object>> result1 = baseMapper.getHouseHoldStatisticsAge(code, AuthUtil.getUserId(), roleType);
         List<Map<String, Object>> result = baseMapper.getHouseHoldStatistics(communityCodeList, AuthUtil.getUserId(), roleType);
         List<Map<String, Object>> result1 = baseMapper.getHouseHoldStatisticsAge(communityCodeList, AuthUtil.getUserId(), roleType);
         objectObjectHashMap.put("gender", result);
         objectObjectHashMap.put("age", result1);
         return objectObjectHashMap;
@@ -721,7 +743,7 @@
      for (Long id : idList) {
         HouseholdEntity householdEntity = getById(id);
         // 如果是业主
         if (null!= householdEntity.getRelationship() && householdEntity.getRelationship() == 1) {
         if (null != householdEntity && null != householdEntity.getRelationship() && householdEntity.getRelationship() == 1) {
            // 查询对应的用户
            User user = userService.getById(householdEntity.getAssociatedUserId());
            // 判断是否还绑定其他的房屋,如果有,则不操作用户
@@ -787,13 +809,18 @@
    */
   @Override
   public List<HouseholdVO> selectHouseholdList(HouseholdVO household) {
      if (household.getLimit() == null) {
         household.setLimit(20);
      }
      List<HouseholdVO> householdVOS = baseMapper.selectHouseholdList(household);
      // 遍历
      for (HouseholdVO householdVO : householdVOS) {
         if (householdVO.getHouseholdLabelList().size() > 0) {
            List<String> labelNameList = householdVO.getHouseholdLabelList().stream().map(householdLabelVO -> householdLabelVO.getLabelName())
               .collect(Collectors.toList());
            householdVO.setLabelName(String.join(",", labelNameList));
         List<HouseholdLabelVO> householdLabelList = householdVO.getHouseholdLabelList();
         if (!householdLabelList.isEmpty()) {
            String labelName = householdLabelList.stream()
               .map(HouseholdLabelVO::getLabelName)
               .collect(Collectors.joining(","));
            householdVO.setLabelName(labelName);
         }
      }
      // 返回