src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.java
@@ -44,7 +44,7 @@ */ List<HouseRentalTenantVO> selectHouseRentalPage(IPage page, @Param("vo") HouseRentalTenantVO houseRental, @Param("list") List<String> list, @Param("gridCodeList") List<String> gridCodeList, @Param("regionChildCodesList") List<String> regionChildCodesList, @Param("isAdministrator") Integer isAdministrator); src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.xml
@@ -54,18 +54,81 @@ jczz_house_rental </sql> <sql id="filterData"> <if test="isAdministrator==2"> <choose> <when test="vo.roleName != null and vo.roleName != ''"> <if test="vo.roleName=='wgy'"> <choose> <when test="gridCodeList !=null and gridCodeList.size()>0"> and jp.grid_code in <foreach collection="gridCodeList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jp.grid_code in ('') </otherwise> </choose> </if> <if test="vo.roleName=='mj'"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jpag.community_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jpag.community_code in ('') </otherwise> </choose> </if> </when> <otherwise> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and ( jg.grid_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> or jpag.community_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> ) </when> <otherwise> and ( jg.grid_code in ('') or jpag.community_code in in ('') ) </otherwise> </choose> </otherwise> </choose> </if> </sql> <!--自定义列表查询--> <select id="selectHouseRentalPage" resultType="org.springblade.modules.house.vo.HouseRentalTenantVO"> SELECT jhr.*,jda.address_name as houseName,b.tenantName,b.phone, SELECT jhr.*, jh.address as houseName, b.tenantName, b.phone, concat(jh.district_name," ",jh.building," ",unit," ",room) as address, case when TIMESTAMPDIFF( MONTH, jhr.rental_time, jhr.due_time )>= 8 then 1 when TIMESTAMPDIFF( MONTH, jhr.rental_time, jhr.due_time )<4 then 3 else 2 end as dldType, if(jhr.termination_time is null,if(date_format(jhr.due_time,'%Y-%m-%d') >= date_format(now(),'%Y-%m-%d'),0,1),2) as status FROM jczz_house_rental jhr JOIN jczz_doorplate_address jda ON jda.address_code = jhr.house_code JOIN jczz_house jh ON jh.house_code = jhr.house_code and jh.is_deleted = 0 LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0 LEFT JOIN jczz_police_affairs_grid jpag on jh.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0 LEFT JOIN ( SELECT jht.housing_rental_id,jht.name as tenantName,jht.phone_number as phone FROM jczz_household jht RIGHT JOIN ( @@ -125,20 +188,7 @@ <if test="vo.startTime != null and vo.startTime != '' and vo.endTime != null and vo.endTime != '' "> AND jhr.create_time BETWEEN #{vo.startTime} and #{vo.endTime} </if> <if test="isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jg.community_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jg.community_code in ('') </otherwise> </choose> </if> <include refid="filterHouseGrid"/> <include refid="filterData"/> order by jhr.create_time desc,jhr.id desc </select> 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; } /**