From 9f8f9d13c42ca8cdccbf351069082a5fdccef2e4 Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Mon, 25 Mar 2024 17:30:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java |  427 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 298 insertions(+), 129 deletions(-)

diff --git a/src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java b/src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
index af67476..7d4063d 100644
--- a/src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
+++ b/src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -32,6 +32,8 @@
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.modules.category.entity.CategoryEntity;
+import org.springblade.modules.category.service.ICategoryService;
 import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity;
 import org.springblade.modules.doorplateAddress.service.IDoorplateAddressService;
 import org.springblade.modules.grid.entity.GridEntity;
@@ -44,6 +46,8 @@
 import org.springblade.modules.house.entity.HouseholdEntity;
 import org.springblade.modules.house.entity.UserHouseLabelEntity;
 import org.springblade.modules.house.service.IHouseholdService;
+import org.springblade.modules.house.vo.HouseholdVO;
+import org.springblade.modules.label.entity.LabelEntity;
 import org.springblade.modules.place.entity.*;
 import org.springblade.modules.place.excel.NinePlaceExcel;
 import org.springblade.modules.place.excel.PlaceAndRelExcel;
@@ -57,11 +61,13 @@
 import org.springblade.modules.police.service.IPoliceAffairsGridService;
 import org.springblade.modules.system.entity.Dept;
 import org.springblade.modules.system.entity.DictBiz;
+import org.springblade.modules.system.entity.Region;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IDeptService;
 import org.springblade.modules.system.service.IDictBizService;
 import org.springblade.modules.system.service.IRegionService;
 import org.springblade.modules.system.service.IUserService;
+import org.springblade.modules.task.vo.TaskLabelReportingEventVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -103,9 +109,6 @@
 	private IGridRangeService gridRangeService;
 
 	@Autowired
-	private IGridmanService gridmanService;
-
-	@Autowired
 	private GridMapper gridMapper;
 
 	@Autowired
@@ -124,7 +127,7 @@
 	@Override
 	public IPage<PlaceVO> selectPlacePage(IPage<PlaceVO> page, PlaceVO place) {
 		// 公共参数设置
-		CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class,place);
+		CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place);
 		List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page,
 			place,
 			commonParamSet.getGridCodeList(),
@@ -169,6 +172,8 @@
 			if (null != one) {
 				placeVO.setId(one.getId());
 			} else {
+				// 扫码来的默认绑定本身
+				placeVO.setHouseCodeBinds(placeVO.getHouseCode());
 				// 新增,地址表中没有或者地址表中有场所表中没有的(是房屋的),扫码进来的
 				save(placeVO);
 			}
@@ -177,7 +182,7 @@
 			// 设置完善状态
 			setPlaceStatus(placeVO);
 			// 房屋编号绑定处理
-//			houseCodeBindHandle(placeVO);
+			houseCodeBindHandle(placeVO);
 			// 更新场所信息
 			flag = updateById(placeVO);
 		} else {
@@ -197,35 +202,94 @@
 			// 新增场所信息
 			flag = save(placeVO);
 		}
+		// 获取请求头中的角色别名
+		String roleName = SpringUtils.getRequestParam("roleName");
+		placeVO.setRoleName(roleName);
 		// 保存场所详情及任务信息
 		savePlaceExtAndTaskInfo(placeVO);
 		// 场所标签信息绑定(更新,调整)
 		placeLabelBind(placeVO);
 		// 网格绑定
 		gridBind(placeVO);
-		// 网格编号绑定场所-新
-		gridCodeBind(placeVO);
 		// 警务网格绑定
 		jwGridCodeBind(placeVO);
+		// 保存从业人员
+		savePlacePractitioner(placeVO);
 		// 返回结果
 		return flag;
 	}
 
+
+	/**
+	 * 保存从业人员
+	 *
+	 * @param placeVO
+	 */
+	private void savePlacePractitioner(PlaceVO placeVO) {
+		if (placeVO.getPlacePractitioner() != null) {
+			IPlacePractitionerService practitionerService = SpringUtil.getBean(IPlacePractitionerService.class);
+			// 查询对应已存在的租户
+			QueryWrapper<PlacePractitionerEntity> wrapper = new QueryWrapper<>();
+			wrapper.eq("place_id", placeVO.getId()).eq("is_deleted",0);
+			List<PlacePractitionerEntity> oldList = practitionerService.list(wrapper);
+			// 取出从业人员信息
+			List<PlacePractitionerEntity> placePractitionerList = placeVO.getPlacePractitioner();
+			for (PlacePractitionerEntity placePractitionerEntity : placePractitionerList) {
+				placePractitionerEntity.setPlaceId(placeVO.getId());
+			}
+			// 申明新增,修改,删除集合
+			List<PlacePractitionerEntity> newList = new ArrayList<>();
+			List<PlacePractitionerEntity> addList = new ArrayList<>();
+			List<PlacePractitionerEntity> updateList = new ArrayList<>();
+			List<PlacePractitionerEntity> removeList = new ArrayList<>();
+			// 遍历设置数据
+			for (PlacePractitionerEntity placePractitionerEntity : placePractitionerList) {
+				if (null == placePractitionerEntity.getId()) {
+					// 新增
+					addList.add(placePractitionerEntity);
+				} else {
+					newList.add(placePractitionerEntity);
+				}
+			}
+			// 遍历去差集,判断是新增还是删除还是更新
+			// 取旧数据和新提交数据差集--删除
+			removeList = oldList.stream().filter(vo -> !newList.stream().map(e ->
+				e.getId()).collect(Collectors.toList()).contains(vo.getId())).collect(Collectors.toList());
+			// 取旧数据和新提交数据交集--更新
+			updateList = newList.stream().filter(vo -> oldList.stream().map(e ->
+				e.getId()).collect(Collectors.toList()).contains(vo.getId())).collect(Collectors.toList());
+
+			// 批量新增
+			if (addList.size() > 0) {
+				practitionerService.saveBatch(addList);
+			}
+			// 批量修改
+			if (updateList.size() > 0) {
+				practitionerService.updateBatchById(updateList);
+			}
+			// 批量删除
+			if (removeList.size() > 0) {
+				practitionerService.removeBatchByIds(removeList);
+			}
+		}
+	}
+
 	/**
 	 * 设置场所的source 来源
+	 *
 	 * @param placeVO
 	 */
 	public void setSource(PlaceVO placeVO) {
-		if (null!=placeVO.getSource()){
+		if (null != placeVO.getSource()) {
 			placeVO.setSource(placeVO.getSource());
-		}else {
+		} else {
 			// 查询该houseCode 是否存在地址总表,如果是,赋值 1,否则2
 			QueryWrapper<DoorplateAddressEntity> wrapper = new QueryWrapper<>();
-			wrapper.eq("address_code",placeVO.getHouseCode());
+			wrapper.eq("address_code", placeVO.getHouseCode());
 			DoorplateAddressEntity one = doorplateAddressService.getOne(wrapper);
-			if (null!=one){
+			if (null != one) {
 				placeVO.setSource(1);
-			}else {
+			} else {
 				placeVO.setSource(2);
 			}
 		}
@@ -236,6 +300,7 @@
 	 *
 	 * @param placeVO
 	 */
+	@Override
 	public void jwGridCodeBind(PlaceVO placeVO) {
 		if (!Strings.isBlank(placeVO.getLng())) {
 			String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() + ")'";
@@ -289,44 +354,47 @@
 	 * @param placeVO
 	 */
 	public void houseCodeBindHandle(PlaceVO placeVO) {
-		List<String> list = Arrays.asList(placeVO.getHouseCodeBinds().split(","));
-		// 先删除原有的绑定
-		QueryWrapper<PlaceDoorEntity> removeQw = new QueryWrapper<>();
-		removeQw.eq("place_id",placeVO.getId());
-		// 删除
-		placeDoorService.remove(removeQw);
-		// 遍历更新
-		for (String houseCode : list) {
-			// 查询是否已存在关联关系
-			QueryWrapper<PlaceDoorEntity> wrapper = new QueryWrapper<>();
-			wrapper.eq("house_code",houseCode);
-			// 查询
-			List<PlaceDoorEntity> placeDoorEntityList = placeDoorService.list(wrapper);
-			if (placeDoorEntityList.size()>0){
-				// 该houseCode 已被绑定
+		if (!Strings.isBlank(placeVO.getHouseCodeBinds())) {
+			List<String> list = Arrays.asList(placeVO.getHouseCodeBinds().split(","));
+			// 先删除原有的绑定
+			QueryWrapper<PlaceDoorEntity> removeQw = new QueryWrapper<>();
+			removeQw.eq("place_id", placeVO.getId());
+			// 删除
+			placeDoorService.remove(removeQw);
+			// 遍历更新
+			for (String houseCode : list) {
+				// 查询是否已存在关联关系
+				QueryWrapper<PlaceDoorEntity> wrapper = new QueryWrapper<>();
+				wrapper.eq("house_code", houseCode);
+				// 查询
+				List<PlaceDoorEntity> placeDoorEntityList = placeDoorService.list(wrapper);
+				if (placeDoorEntityList.size() > 0) {
+					// 该houseCode 已被绑定
 //				errorList.add(houseCode);
-				for (PlaceDoorEntity placeDoorEntity : placeDoorEntityList) {
+					for (PlaceDoorEntity placeDoorEntity : placeDoorEntityList) {
+						placeDoorEntity.setPlaceId(placeVO.getId());
+						// 更新
+						placeDoorService.updateById(placeDoorEntity);
+					}
+				} else {
+					PlaceDoorEntity placeDoorEntity = new PlaceDoorEntity();
+					placeDoorEntity.setHouseCode(houseCode);
 					placeDoorEntity.setPlaceId(placeVO.getId());
-					// 更新
-					placeDoorService.updateById(placeDoorEntity);
+					// 对应插入到关联关系表中
+					placeDoorService.save(placeDoorEntity);
 				}
-			}else {
-				PlaceDoorEntity placeDoorEntity = new PlaceDoorEntity();
-				placeDoorEntity.setHouseCode(houseCode);
-				placeDoorEntity.setPlaceId(placeVO.getId());
-				// 对应插入到关联关系表中
-				placeDoorService.save(placeDoorEntity);
 			}
+			// 处理原场所表houseCode 绑定数据-- 暂不处理原数据的删除
+//		handlePlaceOne(list,placeVO);
 		}
-		// 处理原场所表houseCode 绑定数据
-		handlePlaceOne(list,placeVO);
 	}
 
 	/**
 	 * 处理对应的绑定房屋数据
+	 *
 	 * @param list
 	 */
-	public void handlePlaceOne(List<String> list,PlaceVO place) {
+	public void handlePlaceOne(List<String> list, PlaceVO place) {
 		// 处理对应的绑定房屋数据
 		List<Long> longs = new ArrayList<>();
 		// 把其他单个的场所数据删除
@@ -380,33 +448,13 @@
 	 * @param placeVO
 	 */
 	public void gridBind(PlaceVO placeVO) {
-		if (null != placeVO.getGridId()) {
-			// 判断关联关系表是否存在
-			QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>();
-			wrapper.eq("house_code", placeVO.getHouseCode());
-			GridRangeEntity one = gridRangeService.getOne(wrapper);
-			if (null == one) {
-				// 新增
-				GridRangeEntity gridRangeEntity = new GridRangeEntity();
-				gridRangeEntity.setHouseCode(placeVO.getHouseCode());
-				gridRangeEntity.setGridId(placeVO.getGridId());
-				// 插入
-				gridRangeService.save(gridRangeEntity);
-			} else {
-				// 修改绑定
-				one.setGridId(placeVO.getGridId());
-				// 修改
-				gridRangeService.updateById(one);
-			}
-		} else {
-			// 判断角色,如果是网格员则直接使用网格员的网格id,如果是民警则采用点落面的方式进行获取网格的id
-			if (!Strings.isBlank(placeVO.getRoleName())) {
-				// 网格员角色位置绑定
-				gridmanPositionHandle(placeVO);
-				// 民警角色位置绑定
-				policePositionHandle(placeVO);
-			}
-		}
+		// 判断角色,如果是网格员则直接使用网格员的网格id,如果是民警则采用点落面的方式进行获取网格的id
+//		if (!Strings.isBlank(placeVO.getRoleName()) && placeVO.getRoleName().equals("wgy")) {
+//			// 网格员角色位置绑定
+//			gridmanPositionHandle(placeVO);
+//		}
+		// 都是通过点落面方式,不区分角色
+		policePositionHandle(placeVO);
 	}
 
 	/**
@@ -415,16 +463,13 @@
 	 * @param placeVO
 	 */
 	public void gridCodeBind(PlaceVO placeVO) {
-		// 无网格编号时
-		if (Strings.isBlank(placeVO.getGridCode())) {
-			// 判断角色,如果是网格员则直接使用网格员的网格id,如果是民警则采用点落面的方式进行获取网格的id
-			if (!Strings.isBlank(placeVO.getRoleName())) {
-				// 网格员场所网格编号绑定-新
-				gridmanGridCodePositionHandle(placeVO);
-				// 民警角色时通过位置绑定网格-新
-				policeGridCodePositionHandle(placeVO);
-			}
+		// 判断角色,如果是网格员则直接使用网格员的网格id,如果是民警则采用点落面的方式进行获取网格的id
+		if (!Strings.isBlank(placeVO.getRoleName())) {
+			// 网格员场所网格编号绑定-新
+			gridmanGridCodePositionHandle(placeVO);
 		}
+		// 民警角色时通过位置绑定网格-新
+		policeGridCodePositionHandle(placeVO);
 	}
 
 	/**
@@ -433,10 +478,15 @@
 	 * @param placeVO
 	 */
 	public void gridmanPositionHandle(PlaceVO placeVO) {
-		if (placeVO.getRoleName().equals("网格员")) {
+		if (!Strings.isBlank(placeVO.getRoleName()) && placeVO.getRoleName().equals("wgy")) {
 			// 判断网格员,查询对应网格人对应的网格id
-			Integer gridId = gridmanService.getGridIdByUserId(AuthUtil.getUserId());
-			if (null != gridId) {
+			GridEntity grid = gridService.getGridByUserId(AuthUtil.getUserId());
+			if (null != grid) {
+				// 场所编号绑定
+				placeVO.setGridCode(grid.getGridCode());
+				placeVO.setGridId(grid.getId());
+				// 更新场所网格绑定信息
+				updateById(placeVO);
 				// 判断关联关系表是否存在
 				QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>();
 				wrapper.eq("house_code", placeVO.getHouseCode());
@@ -445,12 +495,14 @@
 					// 新增
 					GridRangeEntity gridRangeEntity = new GridRangeEntity();
 					gridRangeEntity.setHouseCode(placeVO.getHouseCode());
-					gridRangeEntity.setGridId(gridId);
+					gridRangeEntity.setGridId(grid.getId());
+					gridRangeEntity.setGridCode(grid.getGridCode());
 					// 插入
 					gridRangeService.save(gridRangeEntity);
 				} else {
 					// 修改绑定
-					one.setGridId(gridId);
+					one.setGridId(grid.getId());
+					one.setGridCode(grid.getGridCode());
 					// 修改
 					gridRangeService.updateById(one);
 				}
@@ -470,6 +522,7 @@
 			if (null != grid && !Strings.isBlank(grid.getGridCode())) {
 				// 场所编号绑定
 				placeVO.setGridCode(grid.getGridCode());
+				placeVO.setGridId(grid.getId());
 				// 更新场所信息
 				updateById(placeVO);
 			}
@@ -477,19 +530,25 @@
 	}
 
 	/**
-	 * 民警角色位置绑定
+	 * 其他角色时位置绑定
 	 *
 	 * @param placeVO
 	 */
-	private void policePositionHandle(PlaceVO placeVO) {
+	@Override
+	public void policePositionHandle(PlaceVO placeVO) {
 		// 是民警且位置信息存在
-		if (placeVO.getRoleName().equals("民警") && !Strings.isBlank(placeVO.getLng())) {
+		if (!Strings.isBlank(placeVO.getLng())) {
 			//点坐标解析
 			String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() + ")'";
 //			String point = "'POINT(" + villageInfoExcel.getLatitude() + " " + villageInfoExcel.getLongitude() +")'";
 			List<GridEntity> gridEntityList = gridMapper.spatialAnalysis(point);
 			if (gridEntityList.size() > 0) {
 				GridEntity gridEntity = gridEntityList.get(0);
+				// 场所编号绑定
+				placeVO.setGridCode(gridEntity.getGridCode());
+				placeVO.setGridId(gridEntity.getId());
+				// 更新场所信息
+				updateById(placeVO);
 				// 判断关联关系表是否存在
 				QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>();
 				wrapper.eq("house_code", placeVO.getHouseCode());
@@ -499,11 +558,13 @@
 					GridRangeEntity gridRangeEntity = new GridRangeEntity();
 					gridRangeEntity.setHouseCode(placeVO.getHouseCode());
 					gridRangeEntity.setGridId(gridEntity.getId());
+					gridRangeEntity.setGridCode(gridEntity.getGridCode());
 					// 插入
 					gridRangeService.save(gridRangeEntity);
 				} else {
 					// 修改绑定
 					one.setGridId(gridEntity.getId());
+					one.setGridCode(gridEntity.getGridCode());
 					// 修改
 					gridRangeService.updateById(one);
 				}
@@ -528,6 +589,7 @@
 				if (null != gridEntity && !Strings.isBlank(gridEntity.getGridCode())) {
 					// 场所编号绑定
 					placeVO.setGridCode(gridEntity.getGridCode());
+					placeVO.setGridId(gridEntity.getId());
 					// 更新场所信息
 					updateById(placeVO);
 				}
@@ -713,14 +775,48 @@
 	@Transactional(rollbackFor = Exception.class)
 	public void savePlaceExtAndTaskInfo(PlaceVO placeVO) {
 		PlaceExtEntity placeExtEntity = new PlaceExtEntity();
-		placeExtEntity.setPlaceId(placeVO.getId());
 		// 判断是否已存在,已存在则不新增
 		QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>();
 		wrapper.eq("is_deleted", 0)
 			.eq("place_id", placeVO.getId());
+		PlaceExtEntity extServiceOne = placeExtService.getOne(wrapper);
+		if (null == extServiceOne) {
+			// 判断是否有传
+			if (placeVO.getPlaceExtEntity() != null) {
+				placeExtEntity = placeVO.getPlaceExtEntity();
+			}
+			placeExtEntity.setPlaceId(placeVO.getId());
+			// 默认给待完善状态
+			placeExtEntity.setConfirmFlag(4);
+			placeExtEntity.setCreateTime(new Date());
+			placeExtEntity.setUpdateTime(new Date());
+			placeExtEntity.setCreateUser(AuthUtil.getUserId());
+			placeExtEntity.setUpdateUser(AuthUtil.getUserId());
+			// 新增场所详情
+			placeExtService.save(placeExtEntity);
+		} else {
+			if (placeVO.getPlaceExtEntity() != null) {
+				placeExtService.updateById(placeVO.getPlaceExtEntity());
+			}
+		}
+	}
+
+	/**
+	 * 保存场所详情信息
+	 *
+	 * @param placeEntity
+	 */
+	@Transactional(rollbackFor = Exception.class)
+	public void savePlaceExtInfo(PlaceEntity placeEntity) {
+		PlaceExtEntity placeExtEntity = new PlaceExtEntity();
+		placeExtEntity.setPlaceId(placeEntity.getId());
+		// 判断是否已存在,已存在则不新增
+		QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>();
+		wrapper.eq("is_deleted", 0)
+			.eq("place_id", placeEntity.getId());
 		PlaceExtEntity one = placeExtService.getOne(wrapper);
 		if (null == one) {
-			placeExtEntity.setPlaceId(placeVO.getId());
+			placeExtEntity.setPlaceId(placeEntity.getId());
 			// 默认给待完善状态
 			placeExtEntity.setConfirmFlag(4);
 			placeExtEntity.setCreateTime(new Date());
@@ -820,6 +916,13 @@
 				QueryWrapper<PlaceExtEntity> queryWrapper = new QueryWrapper<>();
 				queryWrapper.eq("is_deleted", 0).eq("place_id", placeVO.getId());
 				placeVO.setPlaceExtEntity(placeExtService.getOne(queryWrapper));
+				// 查询从业人员
+				IPlacePractitionerService placePractitionerService = SpringUtils.getBean(IPlacePractitionerService.class);
+				List<PlacePractitionerEntity> entityList = placePractitionerService.list(Wrappers.<PlacePractitionerEntity>lambdaQuery()
+					.eq(PlacePractitionerEntity::getPlaceId, placeVO.getId()));
+				placeVO.setPlacePractitioner(entityList);
+				// 查询绑定的房屋
+				placeVO.setHouseBindList(baseMapper.getHouseBindMap(placeVO.getHouseCodeBinds()));
 			}
 		} else {
 			// 查询地址编码信息(社区派出所相关信息)
@@ -903,8 +1006,8 @@
 		if (!Strings.isBlank(placeExcel.getPhoneNumber()) &&
 			!Strings.isBlank(placeExcel.getName())) {
 			PlaceVO placeVO = new PlaceVO();
-			placeVO.setPhone(placeExcel.getPhoneNumber());
-			placeVO.setUsername(placeExcel.getName());
+			placeVO.setPrincipalPhone(placeExcel.getPhoneNumber());
+			placeVO.setPrincipal(placeExcel.getName());
 			// 更新场所负责人
 			User user = bindUserHandle(placeVO);
 			// 返回
@@ -945,12 +1048,20 @@
 				placeEntity.setSource(3);
 				//一个一个插入,防止同一个表中有相同的数据
 				save(placeEntity);
+				// 插入详情
+				savePlaceExtInfo(placeEntity);
 				// 插入标签关系表
 				savPlaceLabelBind(placeExcel, placeEntity);
 				// 插入关联数据表
 				PlaceRelEntity placeRelEntity = new PlaceRelEntity();
 				placeRelEntity.setPlaceId(placeEntity.getId());
 				placeRelEntity.setStreetName(placeExcel.getStreetName());
+				QueryWrapper<Region> wrapper = new QueryWrapper<>();
+				wrapper.eq("name", placeExcel.getCommunityName());
+				Region region = SpringUtils.getBean(IRegionService.class).getOne(wrapper);
+				if (null != region) {
+					placeRelEntity.setCommunityCode(region.getCode());
+				}
 				placeRelEntity.setCommunityName(placeExcel.getCommunityName());
 				placeRelEntity.setGridName(placeExcel.getGridName());
 				placeRelEntity.setBuildingName(placeExcel.getBuildingName());
@@ -977,6 +1088,8 @@
 				placeEntity.setUpdateUser(AuthUtil.getUserId());
 				//一个一个插入,防止同一个表中有相同的数据
 				updateById(placeEntity);
+				// 插入详情
+				savePlaceExtInfo(placeEntity);
 			}
 		}
 	}
@@ -988,11 +1101,19 @@
 	 */
 	public void savPlaceLabelBind(PlaceAndRelExcel placeExcel, PlaceEntity placeEntity) {
 		if (!Strings.isBlank(placeExcel.getLabelCode())) {
-			PlaceVO placeVO = new PlaceVO();
-			placeVO.setId(placeEntity.getId());
-			placeVO.setLabel(placeExcel.getLabelCode());
-			// 插入标签
-			placeLabelBind(placeVO);
+			// 匹配标签
+			QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<>();
+			wrapper.eq("level", 3).eq("category_name", placeExcel.getLabelCode()).eq("is_deleted", 0);
+			// 查询
+			List<CategoryEntity> list = SpringUtils.getBean(ICategoryService.class).list(wrapper);
+			if (list.size() > 0) {
+				PlaceVO placeVO = new PlaceVO();
+				CategoryEntity categoryEntity = list.get(0);
+				placeVO.setLabel(categoryEntity.getCategoryNo());
+				placeVO.setId(placeEntity.getId());
+				// 插入标签
+				placeLabelBind(placeVO);
+			}
 		}
 	}
 
@@ -1271,43 +1392,46 @@
 	 */
 	@Override
 	public IPage<PlaceVO> selectNinePlacePage(IPage<PlaceVO> page, PlaceVO place) {
-		String roleName = SpringUtils.getRequestParam("roleName");
-		String communityCode = SpringUtils.getRequestParam("communityCode");
-		if (!Strings.isBlank(communityCode)){
-			// 校验社区编号是否合规
-			if(null!=SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
-				place.setCommunityCode(communityCode);
-			}
-		}
-		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
-		Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
-		// 网格编号集合
-		List<String> gridCodeList = new ArrayList<>();
-		// 民警角色
-		if (!Strings.isBlank(roleName)){
-			place.setRoleName(roleName);
-			if(roleName.equals("mj")) {
-				regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
-			}
-			if (roleName.equals("wgy")) {
-				gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId());
-			}
-		}
+//		String roleName = SpringUtils.getRequestParam("roleName");
+//		String communityCode = SpringUtils.getRequestParam("communityCode");
+//		if (!Strings.isBlank(communityCode)){
+//			// 校验社区编号是否合规
+//			if(null!=SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
+//				place.setCommunityCode(communityCode);
+//			}
+//		}
+//		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
+//		Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
+//		// 网格编号集合
+//		List<String> gridCodeList = new ArrayList<>();
+//		// 民警角色
+//		if (!Strings.isBlank(roleName)){
+//			place.setRoleName(roleName);
+//			if(roleName.equals("mj")) {
+//				regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
+//			}
+//			if (roleName.equals("wgy")) {
+//				gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId());
+//			}
+//		}
+		CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place);
+
 		List<String> strings = new ArrayList<>();
-		if (null!=place.getNineType()){
+		if (null != place.getNineType()) {
 			QueryWrapper<DictBiz> queryWrapper = new QueryWrapper<>();
-			queryWrapper.eq("is_deleted",0).eq("dict_key",place.getNineType()).eq("code","nineType");
+			queryWrapper.eq("is_deleted", 0).eq("dict_key", place.getNineType()).eq("code", "nineType");
 			// 先查询当前
 			DictBiz one = dictBizService.getOne(queryWrapper);
 			// 查询本身和子集的key
 			List<DictBiz> list = dictBizService.getList("nineType", one.getId());
-			if (list.size()==0){
+			if (list.size() == 0) {
 				strings.add(place.getNineType().toString());
-			}else {
+			} else {
 				strings = list.stream().map(DictBiz::getDictKey).collect(Collectors.toList());
 			}
 		}
-		List<PlaceVO> placeVOS = baseMapper.selectNinePlacePage(page, place, gridCodeList, regionChildCodesList, isAdministrator,strings);
+		List<PlaceVO> placeVOS = baseMapper.selectNinePlacePage(page, place, commonParamSet.getGridCodeList(),
+			commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), strings);
 		// 返回
 		return page.setRecords(placeVOS);
 	}
@@ -1316,20 +1440,20 @@
 	public List<NinePlaceExcel> export(PlaceVO place) {
 		String roleName = SpringUtils.getRequestParam("roleName");
 		String communityCode = SpringUtils.getRequestParam("communityCode");
-		if (!Strings.isBlank(communityCode)){
+		if (!Strings.isBlank(communityCode)) {
 			// 校验社区编号是否合规
-			if(null!=SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
+			if (null != SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
 				place.setCommunityCode(communityCode);
 			}
 		}
 		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
-		Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
+		Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
 		// 网格编号集合
 		List<String> gridCodeList = new ArrayList<>();
 		// 民警角色
-		if (!Strings.isBlank(roleName)){
+		if (!Strings.isBlank(roleName)) {
 			place.setRoleName(roleName);
-			if(roleName.equals("mj")) {
+			if (roleName.equals("mj")) {
 				regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
 			}
 			if (roleName.equals("wgy")) {
@@ -1337,20 +1461,20 @@
 			}
 		}
 		List<String> strings = new ArrayList<>();
-		if (null!=place.getNineType()){
+		if (null != place.getNineType()) {
 			QueryWrapper<DictBiz> queryWrapper = new QueryWrapper<>();
-			queryWrapper.eq("is_deleted",0).eq("dict_key",place.getNineType()).eq("code","nineType");
+			queryWrapper.eq("is_deleted", 0).eq("dict_key", place.getNineType()).eq("code", "nineType");
 			// 先查询当前
 			DictBiz one = dictBizService.getOne(queryWrapper);
 			// 查询本身和子集的key
 			List<DictBiz> list = dictBizService.getList("nineType", one.getId());
-			if (list.size()==0){
+			if (list.size() == 0) {
 				strings.add(place.getNineType().toString());
-			}else {
+			} else {
 				strings = list.stream().map(DictBiz::getDictKey).collect(Collectors.toList());
 			}
 		}
-		List<NinePlaceExcel> aa = baseMapper.export(place, gridCodeList, regionChildCodesList, isAdministrator,strings);
+		List<NinePlaceExcel> aa = baseMapper.export(place, gridCodeList, regionChildCodesList, isAdministrator, strings);
 		IDictBizService bean = SpringUtils.getBean(IDictBizService.class);
 		List<DictBiz> nineType = bean.list(Wrappers.<DictBiz>lambdaQuery().eq(DictBiz::getCode, "nineType").eq(DictBiz::getIsDeleted, 0));
 		for (NinePlaceExcel ninePlaceExcel : aa) {
@@ -1421,4 +1545,49 @@
 		}
 		return null;
 	}
+
+	/**
+	 * 场所二维码绑定处理
+	 */
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public Object placeDoorBindHandle() {
+		// 查询对应未的场所 house_code_binds 为空,source = 1 的
+		List<PlaceEntity> list = baseMapper.selectPlaceNotDoorBindList();
+		// 遍历
+		for (PlaceEntity placeEntity : list) {
+			// 更新
+			placeEntity.setHouseCodeBinds(placeEntity.getHouseCode());
+			updateById(placeEntity);
+			// 查询绑定关系是否已存在
+			QueryWrapper<PlaceDoorEntity> wrapper = new QueryWrapper<>();
+			wrapper.eq("house_code", placeEntity.getHouseCode()).eq("place_id", placeEntity.getId());
+			// 查询
+			PlaceDoorEntity one = placeDoorService.getOne(wrapper);
+			if (null == one) {
+				// 新增
+				PlaceDoorEntity placeDoorEntity = new PlaceDoorEntity();
+				placeDoorEntity.setPlaceId(placeEntity.getId());
+				placeDoorEntity.setHouseCode(placeEntity.getHouseCode());
+				placeDoorService.save(placeDoorEntity);
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 企业商超列表查询
+	 */
+	@Override
+	public IPage<PlaceVO> selectMallPage(IPage<PlaceVO> page, PlaceVO place) {
+		// 公共参数设置
+		CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place);
+		List<PlaceVO> placeVOS = baseMapper.selectMallPage(page,
+			place,
+			commonParamSet.getGridCodeList(),
+			commonParamSet.getRegionChildCodesList(),
+			commonParamSet.getIsAdministrator());
+		// 返回
+		return page.setRecords(placeVOS);
+	}
 }

--
Gitblit v1.9.3