zhongrj
2024-02-20 19dd4271eeffa8ae57b8529f8b5e327fbf1b8d97
src/main/java/org/springblade/modules/house/service/impl/HouseRentalServiceImpl.java
@@ -22,6 +22,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.grid.service.IGridService;
@@ -72,21 +73,16 @@
    */
   @Override
   public IPage<HouseRentalTenantVO> selectHouseRentalPage(IPage<HouseRentalTenantVO> page, HouseRentalTenantVO houseRental) {
      List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
      Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
      List<String> list = new ArrayList<>();
      if (null!=houseRental.getRoleName() && !houseRental.getRoleName().equals("")){
         if (houseRental.getRoleName().equals("网格员")){
            // 查询对应的房屋地址code
            list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
         }
      }
      if (null!=houseRental.getAuditStatus()){
         if (houseRental.getAuditStatus()==0){
            houseRental.setAuditStatus(2);
         }
      }
      List<HouseRentalTenantVO> houseRentalTenantVOS = baseMapper.selectHouseRentalPage(page, houseRental, list,regionChildCodesList,isAdministrator);
      CommonParamSet<Object> commonParamSet = new CommonParamSet<>().invoke(HouseRentalTenantVO.class, houseRental);
      List<HouseRentalTenantVO> houseRentalTenantVOS = baseMapper.selectHouseRentalPage(page, houseRental,
         commonParamSet.getGridCodeList(),
         commonParamSet.getRegionChildCodesList(),
         commonParamSet.getIsAdministrator());
      for (HouseRentalTenantVO houseRentalTenantVO : houseRentalTenantVOS) {
         if(houseRentalTenantVO.getStatus().equals(1)){
            houseRentalTenantVO.setStatus(30);
@@ -127,18 +123,35 @@
   @Override
   @Transactional(rollbackFor = Exception.class)
   public Boolean add(HouseRentalVO houseRentalVO) {
      boolean flag = false;
      houseRentalVO.setCreateUser(AuthUtil.getUserId());
      houseRentalVO.setCreateTime(new Date());
      houseRentalVO.setUpdateUser(AuthUtil.getUserId());
      houseRentalVO.setUpdateTime(new Date());
      // 网格员新增默认是审核通过
      houseRentalVO.setAuditStatus(1);
      if (!Strings.isBlank(houseRentalVO.getRoleName()) && houseRentalVO.getRoleName().equals("居民")){
      // 获取请求头中的角色别名
      String roleName = SpringUtils.getRequestParam("roleName");
      // 居民
      if (!Strings.isBlank(roleName) && roleName.equals("inhabitant")){
         // 待审核
         houseRentalVO.setAuditStatus(0);
      }
      //保存自身
      boolean save = save(houseRentalVO);
      flag = save(houseRentalVO);
      //保存到住户
      flag = saveHousehold(houseRentalVO, flag);
      return flag;
   }
   /**
    * 保存租户信息
    * @param houseRentalVO
    * @param flag
    * @return
    */
   public boolean saveHousehold(HouseRentalVO houseRentalVO, boolean flag) {
      if (flag && houseRentalVO.getHouseholdVOList().size()>0) {
      List<String> phoneList = new ArrayList<>();
      List<HouseholdEntity> householdEntityList = new ArrayList<>();
      houseRentalVO.getHouseholdVOList().forEach(e -> {
@@ -168,9 +181,9 @@
      } catch (Exception e) {
         log.error("保存用户角色为居民:", e);
      }
      boolean saveBatch = iHouseholdService.saveBatch(householdEntityList);
      return save && saveBatch;
         flag  = iHouseholdService.saveBatch(householdEntityList);
      }
      return flag;
   }
   /**