From 7a1e4d9fe3fe2172d5c4fba524f17ffd73ffbb3e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 08 Jul 2024 10:39:26 +0800
Subject: [PATCH] 公安添加时间过滤

---
 src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java |   76 ++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java b/src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java
index 9238020..af93105 100644
--- a/src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java
+++ b/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;

--
Gitblit v1.9.3