From 3524bd78770d3dd16b8be3e4fa9cba06a42cefa0 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 25 Jan 2024 14:52:25 +0800
Subject: [PATCH] 住户监管柱状图

---
 src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java |  158 +++++++++++++++-----------
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.java            |   12 +
 src/main/java/org/springblade/modules/house/service/IHouseService.java         |   11 +
 src/main/java/org/springblade/modules/house/controller/HouseController.java    |   22 +++
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml             |  154 +++++++++++++++++++++++++
 5 files changed, 284 insertions(+), 73 deletions(-)

diff --git a/src/main/java/org/springblade/modules/house/controller/HouseController.java b/src/main/java/org/springblade/modules/house/controller/HouseController.java
index 368ec9b..b4351ac 100644
--- a/src/main/java/org/springblade/modules/house/controller/HouseController.java
+++ b/src/main/java/org/springblade/modules/house/controller/HouseController.java
@@ -106,6 +106,28 @@
 	}
 
 	/**
+	 * 房屋标签统计
+	 */
+	@GetMapping("/labelStatistics")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "房屋标签统计")
+	public R labelStatistics(HouseVO house) {
+		List<Map<String, Object>>  pages = houseService.labelStatistics( house);
+		return R.data(pages);
+	}
+
+	/**
+	 * 房屋标签区域统计
+	 */
+	@GetMapping("/labelCommunityStatistics")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "房屋标签区域统计")
+	public R labelCommunityStatistics(HouseVO house) {
+		List<Map<String, Object>>  pages = houseService.labelCommunityStatistics( house);
+		return R.data(pages);
+	}
+
+	/**
 	 * 房屋 新增
 	 */
 	@PostMapping("/save")
diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
index a04b877..bc89f99 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
@@ -51,13 +51,15 @@
 
 	/**
 	 * 房屋自定义详情查询
+	 *
 	 * @param house
 	 * @return
 	 */
-    HouseVO getHouseDetail(@Param("house") HouseVO house);
+	HouseVO getHouseDetail(@Param("house") HouseVO house);
 
 	/**
 	 * 导出房屋数据
+	 *
 	 * @param house
 	 * @return
 	 */
@@ -85,4 +87,12 @@
 	List<String> getHouseBuilding(String districtCode);
 
 	List<String> getHouseUnit(String districtCode, String building);
+
+	List<Map<String, Object>>  labelStatistics(@Param("house") HouseVO house,
+											   @Param("regionChildCodesList") List<String> regionChildCodesList,
+											   @Param("isAdministrator") Integer isAdministrator);
+
+	List<Map<String, Object>>  labelCommunityStatistics(@Param("house") HouseVO house,
+														@Param("regionChildCodesList") List<String> regionChildCodesList,
+														@Param("isAdministrator") Integer isAdministrator);
 }
diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
index b913764..c3e33ab 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -181,9 +181,6 @@
                             #{code}
                         </foreach>
                     </when>
-                    <otherwise>
-                        and jg.community_code in ('')
-                    </otherwise>
                 </choose>
             </if>
             <if test="house.parentId != null ">
@@ -393,7 +390,7 @@
             jczz_doorplate_address jda
             LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
             WHERE
-            jc.res_police_user_id  like concat('%',#{userId},'%'))
+            jc.res_police_user_id like concat('%',#{userId},'%'))
             )
         </if>
         ) a
@@ -580,5 +577,154 @@
 
     </select>
 
+    <select id="labelStatistics" resultType="java.util.Map">
+        SELECT
+        jl.id AS id,
+        jl.parent_id AS parentId,
+        jl.label_name AS name,
+        jl.sort,
+        (SELECT
+        count( DISTINCT jhl.house_code )
+        FROM
+        jczz_user_house_label jhl
+        LEFT JOIN jczz_house jh ON jhl.house_code = jh.house_code
+        LEFT JOIN jczz_grid jg ON jg.grid_code = jh.grid_code
+        AND jg.is_deleted = 0
+        LEFT JOIN blade_region br ON br.CODE = jg.community_code
+        <where>
+            <if test="house.id != null ">and jh.id = #{house.id}</if>
+            <if test="house.streetCode != null and house.streetCode != ''">
+                and jda.town_street_code like concat('%',#{house.streetCode},'%')
+            </if>
+            <if test="house.houseCode != null  and house.houseCode != ''">and jh.house_code = #{house.houseCode}</if>
+            <if test="house.districtCode != null  and house.districtCode != ''">and jh.district_code =
+                #{house.districtCode}
+            </if>
+            <if test="house.districtName != null  and house.districtName != ''">
+                and jh.district_name like concat('%',#{house.districtName},'%')
+            </if>
+            <if test="house.townStreetName!=null and house.townStreetName!=''">
+                and br.town_name like concat('%',#{house.townStreetName},'%')
+            </if>
+            <if test="house.neiName!=null and house.neiName!=''">
+                and br.name like concat('%',#{house.neiName},'%')
+            </if>
+            <if test="house.address!=null and house.address!=''">
+                and jh.address like concat('%',#{house.address},'%')
+            </if>
+            <if test="house.houseName != null  and house.houseName != ''">and jh.house_name like
+                concat('%',#{house.houseName},'%')
+            </if>
+            <if test="house.phone != null  and house.phone != ''">and jh.phone = #{house.phone}</if>
+            <if test="house.area != null ">and jh.area = #{house.area}</if>
+            <if test="house.propertyPrice != null ">and jh.property_price = #{house.propertyPrice}</if>
+            <if test="house.serviceDue != null ">and jh.service_due = #{house.serviceDue}</if>
+            <if test="house.floor != null ">and jh.floor = #{house.floor}</if>
+            <if test="house.building != null  and house.building != ''">and jh.building = #{house.building}</if>
+            <if test="house.unit != null  and house.unit != ''">and jh.unit = #{house.unit}</if>
+            <if test="house.room != null  and house.room != ''">and jh.room = #{house.room}</if>
+            <if test="house.buildingNo != null ">and jh.building_no = #{house.buildingNo}</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>
+                </choose>
+            </if>
+            <if test="house.parentId != null ">
+                <if test="house.labelId != null ">
+                    AND jl.id = #{house.labelId}
+                </if>
+                <if test="house.parentId != null ">
+                    AND jl.parent_id = #{house.parentId}
+                </if>
+                and jhl.label_id=jl.id
+                AND jhl.lable_type = 2
+                AND jhl.label_id IS NOT NULL
+            </if>
+            and jh.is_deleted = 0
+        </where>
+        ) count
+        FROM
+        jczz_label jl where is_deleted = 0
+        <if test="house.parentId != null ">
+            AND jl.parent_id = #{house.parentId}
+        </if>
+        and jl.id != '1002'
+
+
+    </select>
+
+
+    <select id="labelCommunityStatistics" resultType="java.util.Map">
+
+        SELECT
+        jc.name,
+        (SELECT
+        count(DISTINCT jhl.house_code)
+        FROM
+        jczz_user_house_label jhl
+        LEFT JOIN jczz_house jh ON jhl.house_code = jh.house_code
+        LEFT JOIN jczz_grid jg ON jg.grid_code = jh.grid_code
+        AND jg.is_deleted = 0
+        LEFT JOIN blade_region br ON br.CODE = jg.community_code
+        WHERE jhl.lable_type = 2 and jg.community_code = jc.code
+        <if test="house.townStreetName!=null and house.townStreetName!=''">
+            and br.town_name like concat('%',#{house.townStreetName},'%')
+        </if>
+        <if test="house.neiName!=null and house.neiName!=''">
+            and br.name like concat('%',#{house.neiName},'%')
+        </if>
+        <if test="house.neiName!=null and house.neiName!=''">
+            and br.name like concat('%',#{house.neiName},'%')
+        </if>
+        <if test="house.address!=null and house.address!=''">
+            and jh.address like concat('%',#{house.address},'%')
+        </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>
+            </choose>
+        </if>
+        <if test="house.parentId != null ">
+            and jh.house_code in (
+            SELECT DISTINCT
+            juhl.house_code
+            FROM
+            jczz_user_house_label juhl
+            LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
+            WHERE
+            juhl.lable_type = 2
+            <if test="house.labelId != null ">
+                AND jl.id = #{house.labelId}
+            </if>
+            <if test="house.parentId != null ">
+                AND jl.parent_id = #{house.parentId}
+            </if>
+            AND juhl.label_id IS NOT NULL
+            )
+        </if>
+        )counts
+        FROM
+        jczz_community jc
+        <where>
+            <if test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                jc.CODE IN
+                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                    #{code}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
+
 
 </mapper>
diff --git a/src/main/java/org/springblade/modules/house/service/IHouseService.java b/src/main/java/org/springblade/modules/house/service/IHouseService.java
index dc8a078..cf1c0e2 100644
--- a/src/main/java/org/springblade/modules/house/service/IHouseService.java
+++ b/src/main/java/org/springblade/modules/house/service/IHouseService.java
@@ -47,24 +47,27 @@
 
 	/**
 	 * 房屋自定义详情查询
+	 *
 	 * @param house
 	 * @return
 	 */
-    HouseVO getHouseDetail(HouseVO house);
+	HouseVO getHouseDetail(HouseVO house);
 
 	/**
 	 * 房屋自定义新增或修改
+	 *
 	 * @param house
 	 * @return
 	 */
 	boolean saveOrUpdateHouse(HouseEntity house);
 
-    void importUserHouse(List<HouseExcel> data, Boolean isCovered);
+	void importUserHouse(List<HouseExcel> data, Boolean isCovered);
 
 	List<HouseExcel> export(HouseVO household);
 
 	/**
 	 * 查询房屋树
+	 *
 	 * @param houseParam
 	 * @return
 	 */
@@ -83,4 +86,8 @@
 	List<String> getHouseBuilding(String districtCode);
 
 	List<String> getHouseUnit(String districtCode, String building);
+
+	List<Map<String, Object>> labelStatistics(HouseVO house);
+
+	List<Map<String, Object>> labelCommunityStatistics(HouseVO house);
 }
diff --git a/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java b/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
index ac81170..0d8fac8 100644
--- a/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
+++ b/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
@@ -87,13 +87,14 @@
 	@Override
 	public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) {
 		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
-		Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
-		List<HouseVO> houseVOS = baseMapper.selectHousePage(page, house,regionChildCodesList,isAdministrator);
+		Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
+		List<HouseVO> houseVOS = baseMapper.selectHousePage(page, house, regionChildCodesList, isAdministrator);
 		return page.setRecords(houseVOS);
 	}
 
 	/**
 	 * 房屋自定义详情查询
+	 *
 	 * @param house
 	 * @return
 	 */
@@ -104,6 +105,7 @@
 
 	/**
 	 * 房屋自定义新增或修改
+	 *
 	 * @param house
 	 * @return
 	 */
@@ -121,7 +123,7 @@
 				// 更新数据
 				return updateById(house);
 			}
-		}else {
+		} else {
 			//自己生成编号
 			// 设置来源( 1:地址总表  2:国控采集)
 			house.setSource(2);
@@ -138,15 +140,16 @@
 
 	/**
 	 * 网格绑定
+	 *
 	 * @param house
 	 */
 	public void gridBind(HouseEntity house) {
-		if (null!=house.getGridId()){
+		if (null != house.getGridId()) {
 			// 判断关联关系表是否存在
 			QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>();
-			wrapper.eq("grid_id",house.getGridId()).eq("house_code",house.getHouseCode());
+			wrapper.eq("grid_id", house.getGridId()).eq("house_code", house.getHouseCode());
 			GridRangeEntity one = gridRangeService.getOne(wrapper);
-			if (null==one){
+			if (null == one) {
 				// 新增
 				GridRangeEntity gridRangeEntity = new GridRangeEntity();
 				gridRangeEntity.setHouseCode(house.getHouseCode());
@@ -160,6 +163,7 @@
 
 	/**
 	 * 导入房屋数据
+	 *
 	 * @param data
 	 * @param isCovered
 	 */
@@ -179,18 +183,20 @@
 
 	/**
 	 * 查询房屋树
+	 *
 	 * @param houseParam
 	 * @return
 	 */
 	@Override
 	public List<HouseTree> getHouseTree(HouseParam houseParam) {
 		List<String> houseCodeList = getHouseCodeList(houseParam);
-		return NodeTreeUtil.getHouseTree(baseMapper.getHouseTree(houseParam,houseCodeList));
+		return NodeTreeUtil.getHouseTree(baseMapper.getHouseTree(houseParam, houseCodeList));
 	}
 
 
 	/**
 	 * 根据角色获取地址编号集合
+	 *
 	 * @param houseParam
 	 * @return
 	 */
@@ -207,6 +213,7 @@
 
 	/**
 	 * 人房数据导入
+	 *
 	 * @param data
 	 * @param isCovered
 	 */
@@ -226,23 +233,24 @@
 
 	/**
 	 * 保存房屋数据
+	 *
 	 * @param houseAndHoldExcel
 	 */
 	@Transactional(rollbackFor = Exception.class)
 	public void saveHouseData(HouseAndHoldExcel houseAndHoldExcel) {
 		// 查询库中是否已存在
 		QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>();
-		wrapper.eq("house_code",houseAndHoldExcel.getHouseCode())
-		.eq("is_deleted",0);
+		wrapper.eq("house_code", houseAndHoldExcel.getHouseCode())
+			.eq("is_deleted", 0);
 		HouseEntity one = getOne(wrapper);
 		// 不存在则插入,存在则不操作
-		if (null == one){
+		if (null == one) {
 			HouseEntity houseEntity = new HouseEntity();
 			houseEntity.setHouseCode(houseAndHoldExcel.getHouseCode());
 			houseEntity.setHouseName(houseAndHoldExcel.getHouseName());
 			houseEntity.setDistrictName(houseAndHoldExcel.getDistrictName());
 			houseEntity.setUnit(houseAndHoldExcel.getUnit());
-			if (!Strings.isBlank(houseAndHoldExcel.getFloor())){
+			if (!Strings.isBlank(houseAndHoldExcel.getFloor())) {
 				houseEntity.setFloor(houseAndHoldExcel.getFloor());
 			}
 			houseEntity.setRoom(houseAndHoldExcel.getRoom());
@@ -264,7 +272,7 @@
 			houseEntity.setUpdateUser(AuthUtil.getUserId().toString());
 			if (!Strings.isBlank(houseAndHoldExcel.getHouseCode())) {
 				houseEntity.setSource(1);
-			}else {
+			} else {
 				houseEntity.setHouseCode(IdUtils.getIdBy36());
 				houseEntity.setSource(2);
 			}
@@ -275,66 +283,67 @@
 
 	/**
 	 * 保存住户数据
+	 *
 	 * @param houseAndHoldExcel
 	 */
 	@Transactional(rollbackFor = Exception.class)
 	public void saveHouseholdData(HouseAndHoldExcel houseAndHoldExcel) {
 		// 查询库中是否已存在
 		QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>();
-		wrapper.eq("house_code",houseAndHoldExcel.getHouseCode())
-			.eq("is_deleted",0)
-			.eq("name",houseAndHoldExcel.getName());
+		wrapper.eq("house_code", houseAndHoldExcel.getHouseCode())
+			.eq("is_deleted", 0)
+			.eq("name", houseAndHoldExcel.getName());
 		HouseholdEntity one = householdService.getOne(wrapper);
 		// 不存在则插入,存在则不操作
-		if (null == one){
+		if (null == one) {
 			HouseholdEntity householdEntity = new HouseholdEntity();
 			householdEntity.setHouseCode(houseAndHoldExcel.getHouseCode());
 			householdEntity.setName(houseAndHoldExcel.getName());
 			householdEntity.setPhoneNumber(houseAndHoldExcel.getPhoneNumber());
-			if (!Strings.isBlank(houseAndHoldExcel.getRoleType())){
+			if (!Strings.isBlank(houseAndHoldExcel.getRoleType())) {
 				householdEntity.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType()));
 			}
 			// 与角色关系
-			if (!Strings.isBlank(houseAndHoldExcel.getRelationship())){
+			if (!Strings.isBlank(houseAndHoldExcel.getRelationship())) {
 				householdEntity.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship()));
 				// 如果是业主,则需要往用户表插入用户
-				if (householdEntity.getRelationship()==1){
+				if (householdEntity.getRelationship() == 1) {
 					saveOrUpdateUser(householdEntity);
 				}
 			}
 			/// 是否主要联系人
-			if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())){
+			if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())) {
 				householdEntity.setIsPrimaryContact(Integer.parseInt(houseAndHoldExcel.getIsPrimaryContact()));
 			}
 			// 居住状态
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())) {
 				householdEntity.setResidentialStatus(Integer.parseInt(houseAndHoldExcel.getResidentialStatus()));
 			}
 			// 性别
-			if (!Strings.isBlank(houseAndHoldExcel.getGender())){
+			if (!Strings.isBlank(houseAndHoldExcel.getGender())) {
 				householdEntity.setGender(Short.parseShort(houseAndHoldExcel.getGender()));
 			}
 			householdEntity.setIdCard(houseAndHoldExcel.getIdCard());
 			// 党员
-			if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())){
+			if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())) {
 				householdEntity.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber()));
 			}
 			householdEntity.setHkmtPass(houseAndHoldExcel.getHkmtPass());
 			householdEntity.setPassport(houseAndHoldExcel.getPassport());
 			// 民族
-			if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())){
+			if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())) {
 				householdEntity.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity()));
 			}
 			// 学历
-			if (!Strings.isBlank(houseAndHoldExcel.getEducation())){
+			if (!Strings.isBlank(houseAndHoldExcel.getEducation())) {
 				householdEntity.setEducation(Integer.parseInt(houseAndHoldExcel.getEducation()));
 			}
 			// 户籍类型
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentType())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentType())) {
 				householdEntity.setResidentType(Integer.parseInt(houseAndHoldExcel.getResidentType().trim()));
 			}
 			// 户籍地区县
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())) {
 				String adCode = shiftResidentResidentAdCode(houseAndHoldExcel.getResidentProvinceAdcode(),
 					houseAndHoldExcel.getResidentCityAdcode(),
 					houseAndHoldExcel.getResidentAdcode());
@@ -343,7 +352,7 @@
 			}
 			householdEntity.setHukouRegistration(houseAndHoldExcel.getHukouRegistration());
 			// 籍贯地区县
-			if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())){
+			if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())) {
 				String adCode = shiftResidentResidentAdCode(null,
 					null,
 					houseAndHoldExcel.getNativePlaceAdcode());
@@ -351,13 +360,13 @@
 				houseAndHoldExcel.setNativePlaceAdcode(adCode);
 			}
 			// 健康状况
-			if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())) {
 				householdEntity.setHealthStatus(Integer.parseInt(houseAndHoldExcel.getHealthStatus()));
 			}
 			householdEntity.setDiseaseName(houseAndHoldExcel.getDiseaseName());
 			householdEntity.setReligiousBelief(houseAndHoldExcel.getReligiousBelief());
 			// 工作状态
-			if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())) {
 				householdEntity.setWorkStatus(Integer.parseInt(houseAndHoldExcel.getWorkStatus()));
 			}
 			householdEntity.setEmployer(houseAndHoldExcel.getEmployer());
@@ -375,12 +384,12 @@
 			householdEntity.setGoOutWhere(houseAndHoldExcel.getGoOutWhere());
 			householdEntity.setGoOutAddr(houseAndHoldExcel.getGoOutAddr());
 			// 婚姻状态
-			if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())) {
 				householdEntity.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus()));
 			}
 			householdEntity.setCardNumber(houseAndHoldExcel.getCardNumber());
 			householdEntity.setOtherContact(houseAndHoldExcel.getOtherContact());
-			if (Strings.isBlank(householdEntity.getHouseCode())){
+			if (Strings.isBlank(householdEntity.getHouseCode())) {
 				// 暂时不处理,导入数据目前都有house_code
 				String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode());
 				// 转换行政区code
@@ -418,55 +427,55 @@
 					}
 				}
 			}
-		}else {
+		} else {
 			// 更新
 			one.setHouseCode(houseAndHoldExcel.getHouseCode());
 			one.setName(houseAndHoldExcel.getName());
 			one.setPhoneNumber(houseAndHoldExcel.getPhoneNumber());
-			if (!Strings.isBlank(houseAndHoldExcel.getRoleType())){
+			if (!Strings.isBlank(houseAndHoldExcel.getRoleType())) {
 				one.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType()));
 			}
 			// 与角色关系
-			if (!Strings.isBlank(houseAndHoldExcel.getRelationship())){
+			if (!Strings.isBlank(houseAndHoldExcel.getRelationship())) {
 				one.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship()));
 				// 如果是业主,则需要往用户表插入用户
-				if (one.getRelationship()==1){
+				if (one.getRelationship() == 1) {
 					saveOrUpdateUser(one);
 				}
 			}
 			/// 是否主要联系人
-			if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())){
+			if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())) {
 				one.setIsPrimaryContact(Integer.parseInt(houseAndHoldExcel.getIsPrimaryContact()));
 			}
 			// 居住状态
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())) {
 				one.setResidentialStatus(Integer.parseInt(houseAndHoldExcel.getResidentialStatus()));
 			}
 			// 性别
-			if (!Strings.isBlank(houseAndHoldExcel.getGender())){
+			if (!Strings.isBlank(houseAndHoldExcel.getGender())) {
 				one.setGender(Short.parseShort(houseAndHoldExcel.getGender()));
 			}
 			one.setIdCard(houseAndHoldExcel.getIdCard());
 			// 党员
-			if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())){
+			if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())) {
 				one.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber()));
 			}
 			one.setHkmtPass(houseAndHoldExcel.getHkmtPass());
 			one.setPassport(houseAndHoldExcel.getPassport());
 			// 民族
-			if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())){
+			if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())) {
 				one.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity()));
 			}
 			// 学历
-			if (!Strings.isBlank(houseAndHoldExcel.getEducation())){
+			if (!Strings.isBlank(houseAndHoldExcel.getEducation())) {
 				one.setEducation(Integer.parseInt(houseAndHoldExcel.getEducation()));
 			}
 			// 户籍类型
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentType())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentType())) {
 				one.setResidentType(Integer.parseInt(houseAndHoldExcel.getResidentType().trim()));
 			}
 			// 户籍地区县
-			if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())){
+			if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())) {
 				String adCode = shiftResidentResidentAdCode(houseAndHoldExcel.getResidentProvinceAdcode(),
 					houseAndHoldExcel.getResidentCityAdcode(),
 					houseAndHoldExcel.getResidentAdcode());
@@ -475,7 +484,7 @@
 			}
 			one.setHukouRegistration(houseAndHoldExcel.getHukouRegistration());
 			// 籍贯地区县
-			if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())){
+			if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())) {
 				String adCode = shiftResidentResidentAdCode(null,
 					null,
 					houseAndHoldExcel.getNativePlaceAdcode());
@@ -483,13 +492,13 @@
 				houseAndHoldExcel.setNativePlaceAdcode(adCode);
 			}
 			// 健康状况
-			if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())) {
 				one.setHealthStatus(Integer.parseInt(houseAndHoldExcel.getHealthStatus()));
 			}
 			one.setDiseaseName(houseAndHoldExcel.getDiseaseName());
 			one.setReligiousBelief(houseAndHoldExcel.getReligiousBelief());
 			// 工作状态
-			if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())) {
 				one.setWorkStatus(Integer.parseInt(houseAndHoldExcel.getWorkStatus()));
 			}
 			one.setEmployer(houseAndHoldExcel.getEmployer());
@@ -507,12 +516,12 @@
 			one.setGoOutWhere(houseAndHoldExcel.getGoOutWhere());
 			one.setGoOutAddr(houseAndHoldExcel.getGoOutAddr());
 			// 婚姻状态
-			if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())){
+			if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())) {
 				one.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus()));
 			}
 			one.setCardNumber(houseAndHoldExcel.getCardNumber());
 			one.setOtherContact(houseAndHoldExcel.getOtherContact());
-			if (Strings.isBlank(one.getHouseCode())){
+			if (Strings.isBlank(one.getHouseCode())) {
 				// 暂时不处理,导入数据目前都有house_code
 				String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode());
 				// 转换行政区code
@@ -553,15 +562,16 @@
 
 	/**
 	 * 现居住地街道转换
+	 *
 	 * @param homeAdcode
 	 * @return
 	 */
 	public String shiftResidentHomeAdcode(String homeAdcode) {
 		// 只根据区县名称查询
 		QueryWrapper<Region> wrapper = new QueryWrapper<>();
-		wrapper.eq("town_name",homeAdcode);
+		wrapper.eq("town_name", homeAdcode);
 		List<Region> list = regionService.list(wrapper);
-		if (list.size()==1){
+		if (list.size() == 1) {
 			return list.get(0).getTownCode();
 		}
 		return "";
@@ -569,28 +579,29 @@
 
 	/**
 	 * 根据名称转成code
+	 *
 	 * @param residentProvinceAdcode 省名称
-	 * @param residentCityAdcode 市名称
-	 * @param residentAdcode 区县名称
+	 * @param residentCityAdcode     市名称
+	 * @param residentAdcode         区县名称
 	 */
-	public String shiftResidentResidentAdCode(String residentProvinceAdcode,String residentCityAdcode,String residentAdcode) {
+	public String shiftResidentResidentAdCode(String residentProvinceAdcode, String residentCityAdcode, String residentAdcode) {
 		if (!Strings.isBlank(residentProvinceAdcode)
-			&& !Strings.isBlank(residentCityAdcode)){
+			&& !Strings.isBlank(residentCityAdcode)) {
 			// 根据省市县三级查询对应的区县code
 			QueryWrapper<Region> wrapper = new QueryWrapper<>();
-			wrapper.eq("province_name",residentProvinceAdcode)
-				.eq("city_name",residentCityAdcode)
-				.eq("district_name",residentAdcode);
+			wrapper.eq("province_name", residentProvinceAdcode)
+				.eq("city_name", residentCityAdcode)
+				.eq("district_name", residentAdcode);
 			List<Region> list = regionService.list(wrapper);
-			if (list.size()>0){
+			if (list.size() > 0) {
 				return list.get(0).getDistrictCode();
 			}
-		}else {
+		} else {
 			// 只根据区县名称查询
 			QueryWrapper<Region> wrapper = new QueryWrapper<>();
-			wrapper.eq("district_name",residentAdcode);
+			wrapper.eq("district_name", residentAdcode);
 			List<Region> list = regionService.list(wrapper);
-			if (list.size()==1){
+			if (list.size() == 1) {
 				return list.get(0).getDistrictCode();
 			}
 		}
@@ -599,19 +610,20 @@
 
 	/**
 	 * 保存或更新用户(业主)
+	 *
 	 * @param householdEntity
 	 */
 	public void saveOrUpdateUser(HouseholdEntity householdEntity) {
-		if (null!=householdEntity.getPhoneNumber() && !householdEntity.getPhoneNumber().equals("")) {
+		if (null != householdEntity.getPhoneNumber() && !householdEntity.getPhoneNumber().equals("")) {
 			//根据手机号查询库里的数据
 			User userParams = new User();
 			userParams.setPhone(householdEntity.getPhoneNumber());
 			User user = userService.getOne(Condition.getQueryWrapper(userParams));
-			if (null!=user) {
+			if (null != user) {
 				//如果用户存在,则该用户id绑定住户
 				householdEntity.setAssociatedUserId(user.getId());
 				// 判断用户是否包含了居民角色,不包含则需更新
-				if (!user.getRoleId().contains("1717429059648606209")){
+				if (!user.getRoleId().contains("1717429059648606209")) {
 					user.setRoleId(user.getRoleId() + ",1717429059648606209");
 					//更新
 					userService.updateById(user);
@@ -639,7 +651,7 @@
 	}
 
 	@Override
-	public Map<String, Object> getHouseStatistics(String code, String roleType,String aoiCode,String buildingCode,String unitCode) {
+	public Map<String, Object> getHouseStatistics(String code, String roleType, String aoiCode, String buildingCode, String unitCode) {
 		Map<String, Object> objectObjectHashMap = new HashMap<>();
 		if (roleType.equals("2")) {
 			//	 result1 查询楼栋数  result2 查询房屋套数 result3 查询住户数  result4 查询单元数
@@ -674,4 +686,18 @@
 	public List<String> getHouseUnit(String districtCode, String building) {
 		return baseMapper.getHouseUnit(districtCode, building);
 	}
+
+	@Override
+	public List<Map<String, Object>>  labelStatistics(HouseVO house) {
+		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
+		Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
+		return baseMapper.labelStatistics(house,regionChildCodesList,isAdministrator);
+	}
+
+	@Override
+	public List<Map<String, Object>> labelCommunityStatistics(HouseVO house) {
+		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
+		Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
+		return baseMapper.labelCommunityStatistics(house,regionChildCodesList,isAdministrator);
+	}
 }

--
Gitblit v1.9.3