| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.repackaged.org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | 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; |
| | |
| | | import org.springblade.modules.grid.mapper.GridMapper; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | 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.place.entity.*; |
| | | import org.springblade.modules.place.excel.ExportPlaceExcel; |
| | | import org.springblade.modules.place.excel.ImportPlaceExcel; |
| | | import org.springblade.modules.place.excel.NinePlaceExcel; |
| | | import org.springblade.modules.place.excel.PlaceAndRelExcel; |
| | | import org.springblade.modules.place.excel.PlaceExcel; |
| | | import org.springblade.modules.place.service.IPlaceExtService; |
| | | import org.springblade.modules.place.service.IPlacePoiLabelService; |
| | | import org.springblade.modules.place.service.IPlaceRelService; |
| | | import org.springblade.modules.place.mapper.PlaceMapper; |
| | | import org.springblade.modules.place.service.*; |
| | | import org.springblade.modules.place.vo.PlacePoiLabelVO; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.place.mapper.PlaceMapper; |
| | | import org.springblade.modules.place.service.IPlaceService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 场所表 服务实现类 |
| | |
| | | private IPlaceRelService placeRelService; |
| | | |
| | | @Autowired |
| | | private IPlaceDoorService placeDoorService; |
| | | |
| | | @Autowired |
| | | private IDoorplateAddressService doorplateAddressService; |
| | | |
| | | @Autowired |
| | |
| | | private IGridRangeService gridRangeService; |
| | | |
| | | @Autowired |
| | | private IGridmanService gridmanService; |
| | | |
| | | @Autowired |
| | | private GridMapper gridMapper; |
| | | |
| | | @Autowired |
| | | private IHouseholdService householdService; |
| | | |
| | | @Autowired |
| | | private IDictBizService dictBizService; |
| | | |
| | | /** |
| | | * 自定义列表查询 |
| | | * |
| | | * @param page |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<PlaceVO> selectPlacePage(IPage<PlaceVO> page, PlaceVO place) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2; |
| | | List<String> list = new ArrayList<>(); |
| | | if (null!=place.getRoleName() && !place.getRoleName().equals("")){ |
| | | if (place.getRoleName().equals("网格员")){ |
| | | // 查询对应的房屋地址code |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place); |
| | | if (StringUtils.isNotBlank(place.getPoiCodes())) { |
| | | place.setPoiCodeList(Arrays.asList(place.getPoiCodes().split(","))); |
| | | } |
| | | List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, place,list,regionChildCodesList,isAdministrator); |
| | | List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, |
| | | place, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator()); |
| | | // 返回 |
| | | return page.setRecords(placeVOS); |
| | | } |
| | | |
| | | /** |
| | | * 查询场所集合信息 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 场所信息自定义新增/修改 |
| | | * |
| | | * @param placeVO |
| | | * @return |
| | | */ |
| | |
| | | placeVO.setUpdateUser(AuthUtil.getUserId()); |
| | | placeVO.setUpdateTime(new Date()); |
| | | // 查看是否包含houseCode,如果有,则更新 |
| | | if (!Strings.isBlank(placeVO.getHouseCode())){ |
| | | if (!Strings.isBlank(placeVO.getHouseCode())) { |
| | | setSource(placeVO); |
| | | // 比对是否1km 范围内(现场)采集 |
| | | setIsScene(placeVO); |
| | | // 更新,先查询场所信息 |
| | | QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("house_code",placeVO.getHouseCode()); |
| | | wrapper.eq("is_deleted", 0).eq("house_code", placeVO.getHouseCode()); |
| | | PlaceEntity one = getOne(wrapper); |
| | | if (null!=one) { |
| | | if (null != one) { |
| | | placeVO.setId(one.getId()); |
| | | }else { |
| | | } else { |
| | | // 扫码来的默认绑定本身 |
| | | placeVO.setHouseCodeBinds(placeVO.getHouseCode()); |
| | | // 新增,地址表中没有或者地址表中有场所表中没有的(是房屋的),扫码进来的 |
| | | save(placeVO); |
| | | } |
| | |
| | | bindUserHandle(placeVO); |
| | | // 设置完善状态 |
| | | setPlaceStatus(placeVO); |
| | | // 房屋编号绑定处理 |
| | | houseCodeBindHandle(placeVO); |
| | | // 更新场所信息 |
| | | flag = updateById(placeVO); |
| | | }else { |
| | | } else { |
| | | // 设置基础数据 |
| | | placeVO.setCreateUser(AuthUtil.getUserId()); |
| | | placeVO.setCreateTime(new Date()); |
| | | // 比对是否1km 范围内(现场)采集 |
| | | setIsSceneNotHouseCode(placeVO); |
| | | // 设置来源( 1:地址总表 2:国控采集) |
| | | placeVO.setSource(2); |
| | | // 并生成36位的houseCode |
| | |
| | | // 新增场所信息 |
| | | flag = save(placeVO); |
| | | } |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | placeVO.setRoleName(roleName); |
| | | // 保存场所详情及任务信息 |
| | | savePlaceExtAndTaskInfo(placeVO); |
| | | // 场所标签信息绑定(更新,调整) |
| | | placeLabelBind(placeVO); |
| | | // 网格绑定 |
| | | gridBind(placeVO); |
| | | // 网格编号绑定场所-新 |
| | | gridCodeBind(placeVO); |
| | | // 房屋编号绑定 |
| | | // houseCodeBind(placeVO); |
| | | // 警务网格绑定 |
| | | jwGridCodeBind(placeVO); |
| | | // 保存从业人员 |
| | | savePlacePractitioner(placeVO); |
| | | // 判断是否校园 |
| | | if (placeVO.getLabel().startsWith("16010")) { |
| | | // 校园的新增一个主体用户和一个通用用户 |
| | | addSchoolUser(placeVO); |
| | | } |
| | | // 返回结果 |
| | | return flag; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 房屋绑定 |
| | | * 保存从业人员 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void houseCodeBind(PlaceVO placeVO) { |
| | | String houseCode = placeVO.getHouseCode(); |
| | | List<String> list = Arrays.asList(houseCode.split(",")); |
| | | if (list.size()>1){ |
| | | // 处理对应的绑定房屋数据 |
| | | List<Long> longs = new ArrayList<>(); |
| | | // 把其他单个的场所数据删除 |
| | | for (String code : list) { |
| | | 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()) { |
| | | placeVO.setSource(placeVO.getSource()); |
| | | } else { |
| | | // 查询该houseCode 是否存在地址总表,如果是,赋值 1,否则2 |
| | | QueryWrapper<DoorplateAddressEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("address_code", placeVO.getHouseCode()); |
| | | DoorplateAddressEntity one = doorplateAddressService.getOne(wrapper); |
| | | if (null != one) { |
| | | placeVO.setSource(1); |
| | | } else { |
| | | placeVO.setSource(2); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 警务网格绑定 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | @Override |
| | | public void jwGridCodeBind(PlaceVO placeVO) { |
| | | if (!Strings.isBlank(placeVO.getLng())) { |
| | | String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() + ")'"; |
| | | // 点落面警务网格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntities |
| | | = SpringUtil.getBean(IPoliceAffairsGridService.class).spatialAnalysis(point); |
| | | if (policeAffairsGridEntities.size() > 0) { |
| | | // 设置警务网格并更新 |
| | | placeVO.setJwGridCode(policeAffairsGridEntities.get(0).getJwGridCode()); |
| | | // 更新 |
| | | updateById(placeVO); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置是否现场采集(1km 范围内) |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void setIsScene(PlaceVO placeVO) { |
| | | if (!Strings.isBlank(placeVO.getX()) && !Strings.isBlank(placeVO.getLng())) { |
| | | Integer placeEntity = baseMapper.comparisonPosition(placeVO); |
| | | if (placeEntity == 1) { |
| | | placeVO.setIsScene(1); |
| | | } else { |
| | | placeVO.setIsScene(2); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置是否现场采集(1km 范围内),非地址总表数据 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void setIsSceneNotHouseCode(PlaceVO placeVO) { |
| | | if (!Strings.isBlank(placeVO.getX()) && !Strings.isBlank(placeVO.getLng())) { |
| | | boolean flag = baseMapper.comparisonPositionNotHouseCode(placeVO); |
| | | if (flag) { |
| | | placeVO.setIsScene(1); |
| | | } else { |
| | | placeVO.setIsScene(2); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 房屋绑定处理 |
| | | * @param placeEntity |
| | | */ |
| | | public void houseCodeBindHandle(PlaceEntity placeEntity) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | placeVO.setHouseCodeBinds(placeEntity.getHouseCodeBinds()); |
| | | // 绑定 |
| | | houseCodeBindHandle(placeVO); |
| | | } |
| | | |
| | | /** |
| | | * 房屋绑定处理 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void houseCodeBindHandle(PlaceVO placeVO) { |
| | | 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) { |
| | | placeDoorEntity.setPlaceId(placeVO.getId()); |
| | | // 更新 |
| | | placeDoorService.updateById(placeDoorEntity); |
| | | } |
| | | } else { |
| | | PlaceDoorEntity placeDoorEntity = new PlaceDoorEntity(); |
| | | placeDoorEntity.setHouseCode(houseCode); |
| | | placeDoorEntity.setPlaceId(placeVO.getId()); |
| | | // 对应插入到关联关系表中 |
| | | placeDoorService.save(placeDoorEntity); |
| | | } |
| | | } |
| | | // 处理原场所表houseCode 绑定数据-- 暂不处理原数据的删除 |
| | | // handlePlaceOne(list,placeVO); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理对应的绑定房屋数据 |
| | | * |
| | | * @param list |
| | | */ |
| | | public void handlePlaceOne(List<String> list, PlaceVO place) { |
| | | // 处理对应的绑定房屋数据 |
| | | List<Long> longs = new ArrayList<>(); |
| | | // 把其他单个的场所数据删除 |
| | | for (String code : list) { |
| | | if (!code.equals(place.getHouseCode())) { |
| | | // 先查询对应的场所id |
| | | QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",code).eq("is_deleted",0); |
| | | wrapper.eq("house_code", code).eq("is_deleted", 0); |
| | | PlaceEntity one = getOne(wrapper); |
| | | if (null!=one){ |
| | | if (null != one) { |
| | | longs.add(one.getId()); |
| | | // 删除对应的单个编号的场所 |
| | | removeById(one.getId()); |
| | | } |
| | | } |
| | | if (longs.size()>0) { |
| | | // 删除对应的详情 |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | } |
| | | }else { |
| | | // 一对一,暂时不处理,后续考虑需加绑定关系表 |
| | | } |
| | | if (longs.size() > 0) { |
| | | // 删除对应的详情 |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | // 删除对应的场所门牌绑定关系信息 |
| | | removePlaceDoor(longs); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置场所完善状态 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | private void setPlaceStatus(PlaceVO placeVO) { |
| | |
| | | && !Strings.isBlank(placeVO.getLocation()) |
| | | && !Strings.isBlank(placeVO.getPlaceName()) |
| | | && !Strings.isBlank(placeVO.getImageUrls()) |
| | | ){ |
| | | && !Strings.isBlank(placeVO.getPrincipalIdCard()) |
| | | ) { |
| | | // 已完善 |
| | | placeVO.setStatus(2); |
| | | }else { |
| | | } else { |
| | | // 未完善 |
| | | placeVO.setStatus(1); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 网格绑定 |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 网格编号绑定 |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | | * 网格员角色位置绑定-grid_id |
| | | * |
| | | * @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("grid_id", gridId).eq("house_code", placeVO.getHouseCode()); |
| | | wrapper.eq("house_code", placeVO.getHouseCode()); |
| | | GridRangeEntity one = gridRangeService.getOne(wrapper); |
| | | if (null == one) { |
| | | // 新增 |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setHouseCode(placeVO.getHouseCode()); |
| | | gridRangeEntity.setGridId(gridId); |
| | | gridRangeEntity.setGridId(grid.getId()); |
| | | gridRangeEntity.setGridCode(grid.getGridCode()); |
| | | // 插入 |
| | | gridRangeService.save(gridRangeEntity); |
| | | }else { |
| | | } else { |
| | | // 修改绑定 |
| | | one.setGridId(placeVO.getGridId()); |
| | | one.setGridId(grid.getId()); |
| | | one.setGridCode(grid.getGridCode()); |
| | | // 修改 |
| | | gridRangeService.updateById(one); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 网格员角色位置绑定-grid_code |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void gridmanGridCodePositionHandle(PlaceVO placeVO) { |
| | |
| | | if (null != grid && !Strings.isBlank(grid.getGridCode())) { |
| | | // 场所编号绑定 |
| | | placeVO.setGridCode(grid.getGridCode()); |
| | | placeVO.setGridId(grid.getId()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 民警角色位置绑定 |
| | | * 其他角色时位置绑定 |
| | | * |
| | | * @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(" + placeVO.getLng() + " " + placeVO.getLat() + ")'"; |
| | | // String point = "'POINT(" + villageInfoExcel.getLatitude() + " " + villageInfoExcel.getLongitude() +")'"; |
| | | GridEntity gridEntity = gridMapper.spatialAnalysis(point); |
| | | if (null != gridEntity) { |
| | | 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("grid_id", gridEntity.getId()).eq("house_code", placeVO.getHouseCode()); |
| | | wrapper.eq("house_code", placeVO.getHouseCode()); |
| | | GridRangeEntity one = gridRangeService.getOne(wrapper); |
| | | if (null == one) { |
| | | // 新增 |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setHouseCode(placeVO.getHouseCode()); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 插入 |
| | | gridRangeService.save(gridRangeEntity); |
| | | }else { |
| | | } else { |
| | | // 修改绑定 |
| | | one.setGridId(placeVO.getGridId()); |
| | | one.setGridId(gridEntity.getId()); |
| | | one.setGridCode(gridEntity.getGridCode()); |
| | | // 修改 |
| | | gridRangeService.updateById(one); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 民警角色时通过位置绑定网格 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | private void policeGridCodePositionHandle(PlaceVO placeVO) { |
| | | // 是民警且位置信息存在 |
| | | if (placeVO.getRoleName().equals("民警") && !Strings.isBlank(placeVO.getLng())) { |
| | | //点坐标解析 |
| | | String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() +")'"; |
| | | String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() + ")'"; |
| | | // String point = "'POINT(" + villageInfoExcel.getLatitude() + " " + villageInfoExcel.getLongitude() +")'"; |
| | | GridEntity gridEntity = gridMapper.spatialAnalysis(point); |
| | | if (null != gridEntity && !Strings.isBlank(gridEntity.getGridCode())) { |
| | | // 场所编号绑定 |
| | | placeVO.setGridCode(gridEntity.getGridCode()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | List<GridEntity> gridEntityList = gridMapper.spatialAnalysis(point); |
| | | if (gridEntityList.size() > 0) { |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | if (null != gridEntity && !Strings.isBlank(gridEntity.getGridCode())) { |
| | | // 场所编号绑定 |
| | | placeVO.setGridCode(gridEntity.getGridCode()); |
| | | placeVO.setGridId(gridEntity.getId()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 场所标签信息绑定入库 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | // 先查询对于的场所是否已有标签信息 |
| | | // 查询对应已存在的从业人员 |
| | | QueryWrapper<PlacePoiLabel> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id",placeVO.getId()); |
| | | wrapper.eq("place_id", placeVO.getId()); |
| | | List<PlacePoiLabel> oldList = placePoiLabelService.list(wrapper); |
| | | if (oldList.size()>0){ |
| | | if (oldList.size() > 0) { |
| | | // 先将老的全部删除,然后批量插入 |
| | | QueryWrapper<PlacePoiLabel> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("place_id",placeVO.getId()); |
| | | queryWrapper.eq("place_id", placeVO.getId()); |
| | | boolean remove = placePoiLabelService.remove(queryWrapper); |
| | | if (remove){ |
| | | if (remove) { |
| | | // 批量新增 |
| | | savePlaceLabel(placeVO); |
| | | } |
| | | }else { |
| | | } else { |
| | | savePlaceLabel(placeVO); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入场所标签信息 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | public void savePlaceLabel(PlaceVO placeVO) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增校方主体账号和通用账号 |
| | | * |
| | | * @param placeVO |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addSchoolUser(PlaceVO placeVO) { |
| | | User newUser = new User(); |
| | | // 查询账号是否存在,存在则不创建 |
| | | long count = userService.count(Wrappers.<User>lambdaQuery() |
| | | .eq(User::getAccount, placeVO.getPlaceName() + "主体")); |
| | | // 如果用户不存在,则新增一个用户 |
| | | if (StringUtils.isNotBlank(placeVO.getPlaceName()) && count <= 0) { |
| | | newUser.setAccount(placeVO.getPlaceName() + "主体"); |
| | | newUser.setName(placeVO.getPlaceName() + "-主体"); |
| | | newUser.setRealName(placeVO.getPlaceName() + "-主体"); |
| | | // 社区群众部门 |
| | | newUser.setDeptId("1727979636479037441"); |
| | | // 校园主体, |
| | | newUser.setRoleId("1780786647371706370"); |
| | | // 默认密码为 123456 |
| | | newUser.setPassword("123456"); |
| | | // 设置机构 |
| | | // 用户新增 |
| | | newUser.setId(null); |
| | | boolean submit = userService.submit(newUser); |
| | | placeVO.setPrincipalAccount(newUser.getId()); |
| | | // 校园通用 |
| | | newUser.setId(null); |
| | | newUser.setPassword("123456"); |
| | | newUser.setRoleId("1780786746076262402"); |
| | | newUser.setAccount(placeVO.getPlaceName() + "通用"); |
| | | newUser.setName(placeVO.getPlaceName() + "-通用"); |
| | | newUser.setRealName(placeVO.getPlaceName() + "-通用"); |
| | | boolean submit2 = userService.submit(newUser); |
| | | placeVO.setUniversalAccount(newUser.getId()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 场所负责人和用户绑定 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public User bindUserHandle(PlaceVO placeVO) { |
| | | User newUser = new User(); |
| | | if (null!=placeVO.getPrincipalPhone() && !placeVO.getPrincipalPhone().equals("")) { |
| | | if (null != placeVO.getPrincipalPhone() && !placeVO.getPrincipalPhone().equals("")) { |
| | | placeVO.setPrincipal(placeVO.getPrincipal()); |
| | | placeVO.setPrincipalPhone(placeVO.getPrincipalPhone()); |
| | | //根据手机号查询库里的数据 |
| | | User userParams = new User(); |
| | | userParams.setPhone(placeVO.getPrincipalPhone()); |
| | | userParams.setIsDeleted(0); |
| | | User user = userService.getOne(Condition.getQueryWrapper(userParams)); |
| | | if (null==user){ |
| | | User userParams1 = new User(); |
| | | userParams1.setAccount(placeVO.getPrincipalPhone()); |
| | | userParams1.setIsDeleted(0); |
| | | user = userService.getOne(Condition.getQueryWrapper(userParams1)); |
| | | } |
| | | |
| | | if (null!=user) { |
| | | List<User> list = userService.getUserListByPhoneOrAccount(placeVO.getPrincipalPhone()); |
| | | if (list.size() > 0) { |
| | | User user = list.get(0); |
| | | //如果用户存在,则该用户id绑定场所 |
| | | placeVO.setPrincipalUserId(user.getId()); |
| | | newUser = user; |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | | if (!user.getRoleId().contains("1717429059648606209")){ |
| | | if (!user.getRoleId().contains("1717429059648606209")) { |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | //更新 |
| | | userService.updateById(user); |
| | |
| | | //绑定id |
| | | placeVO.setPrincipalUserId(newUser.getId()); |
| | | //给人员打上场所负责人的标签 |
| | | baseMapper.saveUserLabel(newUser.getId(),1002); |
| | | baseMapper.saveUserLabel(newUser.getId(), 1002); |
| | | } |
| | | } |
| | | return newUser; |
| | |
| | | |
| | | /** |
| | | * 保存场所详情及任务信息 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | @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()); |
| | | 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()); |
| | |
| | | |
| | | /** |
| | | * 历史场所挂接处理-临时 |
| | | * |
| | | * @param place |
| | | * @return |
| | | */ |
| | |
| | | // 遍历 |
| | | for (PlaceVO placeVO : list) { |
| | | User user = bindUserHandle(placeVO); |
| | | if (null!=user){ |
| | | if (null != user) { |
| | | placeVO.setPrincipalUserId(user.getId()); |
| | | //更新场所用户id绑定 |
| | | baseMapper.updatePlaceEntity(placeVO); |
| | |
| | | |
| | | /** |
| | | * 历史场所标签挂接处理-临时 |
| | | * |
| | | * @param place |
| | | * @return |
| | | */ |
| | |
| | | List<PlaceVO> list = baseMapper.getAllHistoryPlace(); |
| | | // 遍历 |
| | | for (PlaceVO placeVO : list) { |
| | | if (null!=placeVO.getLabel()){ |
| | | if (null != placeVO.getLabel()) { |
| | | String[] split = placeVO.getLabel().split(","); |
| | | for (String s : split) { |
| | | PlacePoiLabel placePoiLabel = new PlacePoiLabel(); |
| | |
| | | |
| | | /** |
| | | * 场所表 自定义详情查询 |
| | | * |
| | | * @param place |
| | | * @return |
| | | */ |
| | |
| | | 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 { |
| | | } else { |
| | | // 查询地址编码信息(社区派出所相关信息) |
| | | if (!Strings.isBlank(place.getHouseCode())) { |
| | | QueryWrapper<DoorplateAddressEntity> queryWrapper = new QueryWrapper<>(); |
| | |
| | | if (null != addressEntity) { |
| | | placeVO = new PlaceVO(); |
| | | placeVO.setDoorplateAddressEntity(addressEntity); |
| | | placeVO.setHouseCode(addressEntity.getAddressCode()); |
| | | placeVO.setLng(addressEntity.getX()); |
| | | placeVO.setLat(addressEntity.getY()); |
| | | placeVO.setLocation(addressEntity.getAddressName()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 场所数据到导入 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importPlace(List<PlaceExcel> data, Boolean isCovered) { |
| | | for (PlaceExcel placeExcel : data) { |
| | | public String importPlace(List<ImportPlaceExcel> data, Boolean isCovered) { |
| | | int totalNum = data.size(); |
| | | int importNum = 0; |
| | | int updateNum = 0; |
| | | int errorNum = 0; |
| | | for (ImportPlaceExcel placeExcel : data) { |
| | | if (Strings.isBlank(placeExcel.getPlaceName()) || Strings.isBlank(placeExcel.getHouseCode())){ |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | PlaceEntity placeEntity = Objects.requireNonNull(BeanUtil.copy(placeExcel, PlaceEntity.class)); |
| | | Long userId = updateUser(placeExcel); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | placeEntity.setIsNine(1); |
| | | placeEntity.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | } |
| | | // 阵地类型处理 |
| | | if (!Strings.isBlank(placeExcel.getFrontType())) { |
| | | placeEntity.setIsFront(1); |
| | | placeEntity.setFrontType(Integer.parseInt(placeExcel.getFrontType())); |
| | | } |
| | | // 无诈类别 |
| | | if (!Strings.isBlank(placeExcel.getNoExplosionCategory())){ |
| | | placeEntity.setNoExplosionCategory(Integer.parseInt(placeExcel.getNoExplosionCategory())); |
| | | } |
| | | // 三级单位 |
| | | if (!Strings.isBlank(placeExcel.getThreeFireProtection())){ |
| | | if (placeExcel.getThreeFireProtection().equals("是")){ |
| | | placeEntity.setThreeFireProtection(1); |
| | | } |
| | | if (placeExcel.getThreeFireProtection().equals("否")){ |
| | | placeEntity.setThreeFireProtection(2); |
| | | } |
| | | } |
| | | String[] split = placeExcel.getHouseCode().split(","); |
| | | placeEntity.setHouseCode(split[0]); |
| | | placeEntity.setHouseCodeBinds(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | // houseCode 关联处理 来源 1:地址总表 2:国控采集 3:商超 |
| | | houseCodeHandle(placeExcel, placeEntity); |
| | | // 网格绑定处理 |
| | | importGridHandle(placeExcel, placeEntity); |
| | | // 判断是否存在,不存在则插入,否则不操作 |
| | | QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0) |
| | | .eq("house_code",placeExcel.getHouseCode()); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("house_code", placeExcel.getHouseCode()); |
| | | PlaceEntity one = getOne(wrapper); |
| | | if (null == one){ |
| | | Long userId = updateUser(placeExcel); |
| | | // 插入场所 |
| | | PlaceEntity placeEntity = new PlaceEntity(); |
| | | placeEntity.setHouseCode(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | placeEntity.setPrincipal(placeExcel.getName()); |
| | | placeEntity.setPrincipalPhone(placeExcel.getPhoneNumber()); |
| | | placeEntity.setCreateTime(new Date()); |
| | | placeEntity.setCreateUser(AuthUtil.getUserId()); |
| | | placeEntity.setUpdateTime(new Date()); |
| | | placeEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | //一个一个插入,防止同一个表中有相同的数据 |
| | | if (null == one) { |
| | | // 新增 |
| | | save(placeEntity); |
| | | importNum++; |
| | | // 保存详情 |
| | | savePlaceExt(placeEntity,placeExcel); |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | placeVO.setLabel(placeExcel.getLabelCode()); |
| | | // 处理 |
| | | placeLabelBind(placeVO); |
| | | } |
| | | // 房屋编号绑定处理 |
| | | houseCodeBindHandle(placeEntity); |
| | | } else { |
| | | updateNum++; |
| | | // 是否覆盖更新 |
| | | if (isCovered) { |
| | | // 更新场所 |
| | | placeEntity.setId(one.getId()); |
| | | // 更新 |
| | | updateById(placeEntity); |
| | | importNum++; |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(one.getId()); |
| | | placeVO.setLabel(placeExcel.getLabelCode()); |
| | | // 处理 |
| | | placeLabelBind(placeVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | StringBuilder builder = new StringBuilder("导入完成!"); |
| | | builder.append("其中本次表格共有 ").append(totalNum).append(" 条数据,") |
| | | .append("成功导入 ").append(importNum).append(" 条数据。"); |
| | | if (updateNum>0) { |
| | | builder.append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | } |
| | | if (errorNum>0){ |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无企业(店铺)名称信息或无地址编号未导入!"); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 保存场所详情信息 |
| | | * @param placeEntity |
| | | * @param placeExcel |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void savePlaceExt(PlaceEntity placeEntity, ImportPlaceExcel placeExcel) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | | placeExtEntity.setLegalPerson(placeExcel.getLegalPerson()); |
| | | placeExtEntity.setLegalTel(placeExcel.getLegalTel()); |
| | | placeExtEntity.setLegalIdCard(placeExcel.getLegalIdCard()); |
| | | // 设置详情 |
| | | placeVO.setPlaceExtEntity(placeExtEntity); |
| | | // 保存详情 |
| | | savePlaceExtAndTaskInfo(placeVO); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | public void houseCodeHandle(ImportPlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getHouseCode())) { |
| | | placeEntity.setSource(1); |
| | | // 设置经纬度及地址 |
| | | DoorplateAddressEntity doorplateAddressEntity |
| | | = doorplateAddressService.getOne(Wrappers.<DoorplateAddressEntity>lambdaQuery() |
| | | .eq(DoorplateAddressEntity::getAddressCode, placeExcel.getHouseCode()).last("limit 1")); |
| | | if (null!=doorplateAddressEntity){ |
| | | placeEntity.setLng(doorplateAddressEntity.getX()); |
| | | placeEntity.setLat(doorplateAddressEntity.getY()); |
| | | placeEntity.setLocation(doorplateAddressEntity.getAddressName()); |
| | | placeEntity.setBuildingCode(doorplateAddressEntity.getBuildingCode()); |
| | | placeEntity.setAoiCode(doorplateAddressEntity.getAoiCode()); |
| | | } |
| | | } else { |
| | | placeEntity.setSource(2); |
| | | // 并生成36位的houseCode |
| | | placeEntity.setHouseCode(IdUtils.getIdBy36()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入是网格数据绑定处理 |
| | | * |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | private void importGridHandle(ImportPlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (Strings.isNotBlank(placeExcel.getCommunityName()) && Strings.isNotBlank(placeExcel.getGridName())) { |
| | | // 查询对应的网格信息 |
| | | GridEntity gridEntity = gridService.getGridInfoByParam(placeExcel.getCommunityName(), placeExcel.getGridName()); |
| | | if (null != gridEntity) { |
| | | // 设置场所范围 |
| | | placeEntity.setGridId(gridEntity.getId()); |
| | | placeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 更新网格范围绑定 |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | gridRangeEntity.setHouseCode(placeEntity.getHouseCode()); |
| | | UpdateWrapper<GridRangeEntity> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("house_code", placeEntity.getHouseCode()); |
| | | gridRangeService.update(gridRangeEntity, updateWrapper); |
| | | } |
| | | } else if (StringUtils.isNotBlank(placeEntity.getLat()) && StringUtils.isNotBlank(placeEntity.getLng())) { |
| | | // 点落面 |
| | | setGridInfo(placeEntity); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置警格网格信息 |
| | | * |
| | | * @param placeEntity |
| | | */ |
| | | public void setGridInfo(PlaceEntity placeEntity) { |
| | | // 根据位置设置网格,警格编号 |
| | | IGridService gridService = SpringUtils.getBean(IGridService.class); |
| | | IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class); |
| | | String point = "'POINT(" + placeEntity.getLng() + " " + placeEntity.getLat() + ")'"; |
| | | // 点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size() > 0) { |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | // 设置场所范围 |
| | | placeEntity.setGridId(gridEntity.getId()); |
| | | placeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 更新网格范围绑定 |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | gridRangeEntity.setHouseCode(placeEntity.getHouseCode()); |
| | | UpdateWrapper<GridRangeEntity> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("house_code", placeEntity.getHouseCode()); |
| | | gridRangeService.update(gridRangeEntity, updateWrapper); |
| | | } |
| | | // 点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size() > 0) { |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | placeEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新用户信息 |
| | | * |
| | | * @param placeExcel |
| | | * @return |
| | | */ |
| | | public Long updateUser(PlaceExcel placeExcel) { |
| | | if (!Strings.isBlank(placeExcel.getPhoneNumber()) && |
| | | !Strings.isBlank(placeExcel.getName())) { |
| | | public Long updateUser(ImportPlaceExcel placeExcel) { |
| | | if (!Strings.isBlank(placeExcel.getPrincipal()) && |
| | | !Strings.isBlank(placeExcel.getPrincipalPhone())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setPhone(placeExcel.getPhoneNumber()); |
| | | placeVO.setUsername(placeExcel.getName()); |
| | | placeVO.setPrincipal(placeExcel.getPrincipal()); |
| | | placeVO.setPrincipalPhone(placeExcel.getPrincipalPhone()); |
| | | // 更新场所负责人 |
| | | User user = bindUserHandle(placeVO); |
| | | // 返回 |
| | |
| | | |
| | | /** |
| | | * 更新用户信息 |
| | | * |
| | | * @param placeExcel |
| | | * @return |
| | | */ |
| | |
| | | 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); |
| | | // 返回 |
| | |
| | | |
| | | /** |
| | | * 场所(商超)导入 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | |
| | | for (PlaceAndRelExcel placeExcel : data) { |
| | | // 判断是否存在,不存在则插入,否则不操作 |
| | | PlaceEntity one = baseMapper.getPlaceAndRelInfo(placeExcel); |
| | | if (null == one){ |
| | | if (null == one) { |
| | | Long userId = updateUser(placeExcel); |
| | | // 插入场所 |
| | | PlaceEntity placeEntity = new PlaceEntity(); |
| | |
| | | placeEntity.setSource(3); |
| | | //一个一个插入,防止同一个表中有相同的数据 |
| | | save(placeEntity); |
| | | // 插入详情 |
| | | savePlaceExtInfo(placeEntity); |
| | | // 插入标签关系表 |
| | | savPlaceLabelBind(placeExcel,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()); |
| | |
| | | placeRelEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 新增 |
| | | placeRelService.save(placeRelEntity); |
| | | }else { |
| | | } else { |
| | | // 只更新商铺信息 |
| | | Long userId = updateUser(placeExcel); |
| | | // 插入场所 |
| | |
| | | placeEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | //一个一个插入,防止同一个表中有相同的数据 |
| | | updateById(placeEntity); |
| | | // 插入详情 |
| | | savePlaceExtInfo(placeEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入标签关系表 |
| | | * |
| | | * @param placeExcel |
| | | */ |
| | | 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); |
| | | public void savPlaceLabelBind(PlaceAndRelExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | // 匹配标签 |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | for (PlaceEntity placeEntity : list) { |
| | | // 查询对应的用户信息 |
| | | User user = userService.getById(placeEntity.getPrincipalUserId()); |
| | | if (null!=user) { |
| | | if (null != user) { |
| | | // 设置场所负责人,手机号 |
| | | if (null != user.getRealName() && !user.getRealName().equals("")) { |
| | | placeEntity.setPrincipal(user.getRealName()); |
| | |
| | | |
| | | /** |
| | | * 自定义修改 |
| | | * |
| | | * @param placeVO |
| | | * @return |
| | | */ |
| | |
| | | // 处理单个 |
| | | String labelCode = placePoiLabel.getPoiCode().toString(); |
| | | // 切割成三个,分别是大类,中类,小类 |
| | | String bigString = labelCode.substring(0,2); |
| | | String midString = labelCode.substring(0,4); |
| | | String bigString = labelCode.substring(0, 2); |
| | | String midString = labelCode.substring(0, 4); |
| | | // 大类 |
| | | PlacePoiLabel big = new PlacePoiLabel(); |
| | | big.setPlaceId(placePoiLabel.getPlaceId()); |
| | |
| | | big.setType(1); |
| | | // 保存前先判断 |
| | | QueryWrapper<PlacePoiLabel> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("place_id",placePoiLabel.getPlaceId()).eq("poi_code",Integer.parseInt(bigString)); |
| | | queryWrapper.eq("place_id", placePoiLabel.getPlaceId()).eq("poi_code", Integer.parseInt(bigString)); |
| | | PlacePoiLabel one = placePoiLabelService.getOne(queryWrapper); |
| | | if (null==one) { |
| | | if (null == one) { |
| | | placePoiLabelService.save(big); |
| | | } |
| | | // 中类 |
| | |
| | | mid.setType(2); |
| | | // 保存前先判断 |
| | | QueryWrapper<PlacePoiLabel> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id",placePoiLabel.getPlaceId()).eq("poi_code",Integer.parseInt(midString)); |
| | | wrapper.eq("place_id", placePoiLabel.getPlaceId()).eq("poi_code", Integer.parseInt(midString)); |
| | | PlacePoiLabel two = placePoiLabelService.getOne(wrapper); |
| | | if (null==two) { |
| | | if (null == two) { |
| | | placePoiLabelService.save(mid); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 历史场所详情数据处理 |
| | | * |
| | | * @param place |
| | | * @return |
| | | */ |
| | |
| | | // 遍历更新 |
| | | for (PlaceEntity placeEntity : list) { |
| | | QueryWrapper<PlaceExtEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("place_id",placeEntity.getId()).eq("is_deleted",0); |
| | | queryWrapper.eq("place_id", placeEntity.getId()).eq("is_deleted", 0); |
| | | PlaceExtEntity one = placeExtService.getOne(queryWrapper); |
| | | if (null==one){ |
| | | if (null == one) { |
| | | // 新增 |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | | if (null!=placeEntity.getPrincipalUserId()){ |
| | | if (null != placeEntity.getPrincipalUserId()) { |
| | | // 待审核 |
| | | placeExtEntity.setConfirmFlag(1); |
| | | }else { |
| | | } else { |
| | | // 待完善 |
| | | placeExtEntity.setConfirmFlag(4); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 商超数据处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | List<PlaceEntity> placeEntityList = baseMapper.placeAndRelHandle(); |
| | | // 处理 |
| | | for (PlaceEntity placeEntity : placeEntityList) { |
| | | if (Strings.isBlank(placeEntity.getHouseCode())){ |
| | | if (Strings.isBlank(placeEntity.getHouseCode())) { |
| | | // 并生成36位的houseCode |
| | | placeEntity.setHouseCode(IdUtils.getIdBy36()); |
| | | // 商超数据 |
| | |
| | | |
| | | /** |
| | | * 根据编号集合查询对应的场所(按颜色区分近多少天没有发过任务的场所) |
| | | * |
| | | * @param stringList |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PlaceVO> getPlaceListByParam(List<String> stringList,String tableName) { |
| | | return baseMapper.getPlaceListByParam(stringList,tableName); |
| | | public List<PlaceVO> getPlaceListByParam(List<String> stringList, String tableName) { |
| | | return baseMapper.getPlaceListByParam(stringList, tableName); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param longs |
| | | * @return |
| | | */ |
| | |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | // 删除对应的门牌绑定信息 |
| | | removePlaceDoor(longs); |
| | | // 返回 |
| | | return removeByIds; |
| | | } |
| | | |
| | | /** |
| | | * 删除场所负责人对应的用户 |
| | | * |
| | | * @param longs |
| | | */ |
| | | public void removeUser(List<Long> longs) { |
| | | // 遍历 |
| | | for (Long id : longs) { |
| | | PlaceEntity placeEntity = getById(id); |
| | | if (null!=placeEntity.getPrincipalUserId()){ |
| | | if (null != placeEntity.getPrincipalUserId()) { |
| | | User user = userService.getById(placeEntity.getPrincipalUserId()); |
| | | if (ObjectUtil.isEmpty(user)) { |
| | | return; |
| | | } |
| | | // 查询场所判断是否还绑定有其他的场所 |
| | | QueryWrapper<PlaceEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0).eq("principal_user_id",user.getId()); |
| | | queryWrapper.eq("is_deleted", 0).eq("principal_user_id", user.getId()); |
| | | List<PlaceEntity> placeEntityList = list(queryWrapper); |
| | | // 如果没有(1个 当前的还没有删除) |
| | | if (placeEntityList.size()==1){ |
| | | if (placeEntityList.size() == 1) { |
| | | // 判断角色 |
| | | if (!Strings.isBlank(user.getRoleId())){ |
| | | if (!Strings.isBlank(user.getRoleId())) { |
| | | // 判断是否还绑定其他的房屋,如果有,则不操作用户 |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("associated_user_id",user.getId()); |
| | | wrapper.eq("is_deleted", 0).eq("associated_user_id", user.getId()); |
| | | List<HouseholdEntity> householdEntityList = householdService.list(wrapper); |
| | | // 即没有房屋和场所了就删除对应的居民角色 |
| | | if (householdEntityList.size()==0) { |
| | | if (householdEntityList.size() == 0) { |
| | | List<String> stringList = Arrays.asList(user.getRoleId().split(",")); |
| | | // 查看当前用户的角色是否只有一个 |
| | | if (stringList.size() > 1) { |
| | |
| | | |
| | | /** |
| | | * 删除场所对应的详情 |
| | | * |
| | | * @param longs |
| | | */ |
| | | public void removePlaceExt(List<Long> longs) { |
| | | for (Long id : longs) { |
| | | QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id",id); |
| | | wrapper.eq("place_id", id); |
| | | placeExtService.remove(wrapper); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除对应的标签绑定信息 |
| | | * |
| | | * @param longs |
| | | */ |
| | | public void removePlaceLabel(List<Long> longs) { |
| | | for (Long id : longs) { |
| | | QueryWrapper<PlacePoiLabel> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id",id); |
| | | wrapper.eq("place_id", id); |
| | | placePoiLabelService.remove(wrapper); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除对应的门牌绑定信息 |
| | | * |
| | | * @param longs |
| | | */ |
| | | public void removePlaceDoor(List<Long> longs) { |
| | | for (Long id : longs) { |
| | | QueryWrapper<PlaceDoorEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id", id); |
| | | placeDoorService.remove(wrapper); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 九小场所档案 |
| | | * |
| | | * @param page |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @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()); |
| | | // } |
| | | // } |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place); |
| | | |
| | | List<String> strings = new ArrayList<>(); |
| | | if (null != place.getNineType()) { |
| | | QueryWrapper<DictBiz> queryWrapper = new QueryWrapper<>(); |
| | | 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) { |
| | | strings.add(place.getNineType().toString()); |
| | | } else { |
| | | strings = list.stream().map(DictBiz::getDictKey).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | List<PlaceVO> placeVOS = baseMapper.selectNinePlacePage(page, place, commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), strings); |
| | | // 返回 |
| | | return page.setRecords(placeVOS); |
| | | } |
| | | |
| | | @Override |
| | | public List<NinePlaceExcel> export(PlaceVO place) { |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(PlaceVO.class, place); |
| | | List<String> strings = new ArrayList<>(); |
| | | if (null != place.getNineType()) { |
| | | QueryWrapper<DictBiz> queryWrapper = new QueryWrapper<>(); |
| | | 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) { |
| | | strings.add(place.getNineType().toString()); |
| | | } else { |
| | | strings = list.stream().map(DictBiz::getDictKey).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | List<NinePlaceExcel> aa = baseMapper.export(place, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator(), |
| | | 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) { |
| | | for (DictBiz dictBiz : nineType) { |
| | | if (StringUtils.isNotBlank(ninePlaceExcel.getNineType()) && ninePlaceExcel.getNineType().equals(dictBiz.getDictKey())) { |
| | | if (ninePlaceExcel.getNineType().contains("10,11,12")) { |
| | | ninePlaceExcel.setNineType("小学校(幼儿园、校外培训机构)- " + dictBiz.getDictValue()); |
| | | } else if (ninePlaceExcel.getNineType().contains("13,14,15")) { |
| | | ninePlaceExcel.setNineType("小医院(诊所、养老院)- " + dictBiz.getDictValue()); |
| | | } else { |
| | | ninePlaceExcel.setNineType(dictBiz.getDictValue()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return aa; |
| | | } |
| | | |
| | | /** |
| | | * 场所警务网格处理 |
| | | */ |
| | | @Override |
| | | public Object placeJwGridCodeHandle() { |
| | | // 查询 警务网格为空的数据 |
| | | List<PlaceEntity> list = baseMapper.getPlaceNotJwGridCode(); |
| | | // 遍历 |
| | | for (PlaceEntity placeEntity : list) { |
| | | if (!Strings.isBlank(placeEntity.getLng())) { |
| | | // 空间分析 |
| | | //点坐标解析 |
| | | String point = "'POINT(" + placeEntity.getLng() + " " + placeEntity.getLat() + ")'"; |
| | | //String point = "'POINT(" + villageInfoExcel.getLatitude() + " " + villageInfoExcel.getLongitude() +")'"; |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntities |
| | | = SpringUtil.getBean(IPoliceAffairsGridService.class).spatialAnalysis(point); |
| | | if (policeAffairsGridEntities.size() > 0) { |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntities.get(0); |
| | | placeEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | // 更新 |
| | | updateById(placeEntity); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 场所综治网格处理 |
| | | */ |
| | | @Override |
| | | public Object placeGridCodeHandle() { |
| | | // 查询 综治网格为空的数据 |
| | | List<PlaceEntity> list = baseMapper.getPlaceNotGridCode(); |
| | | // 遍历 |
| | | for (PlaceEntity placeEntity : list) { |
| | | if (!Strings.isBlank(placeEntity.getLng())) { |
| | | // 空间分析 |
| | | //点坐标解析 |
| | | String point = "'POINT(" + placeEntity.getLng() + " " + placeEntity.getLat() + ")'"; |
| | | //String point = "'POINT(" + villageInfoExcel.getLatitude() + " " + villageInfoExcel.getLongitude() +")'"; |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size() > 0) { |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | placeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 更新 |
| | | updateById(placeEntity); |
| | | } |
| | | } |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有场所数据 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PlaceVO> getAllList(int i, int size) { |
| | | return baseMapper.getAllList(i, size); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有场所数据总数 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int getAllListTotal() { |
| | | return baseMapper.getAllListTotal(); |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的社区编号 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String getCommunityCode(Long id) { |
| | | return baseMapper.getCommunityCode(id); |
| | | } |
| | | |
| | | /** |
| | | * 导出场所信息 |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ExportPlaceExcel> exportPlaceList(PlaceVO place) { |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place); |
| | | return baseMapper.exportPlaceList(place, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator() |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 查询附近场所 |
| | | * @param lat |
| | | * @param lng |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PlaceVO> getNearbyPlaceList(String lat, String lng) { |
| | | return baseMapper.getNearbyPlaceList(lat, lng); |
| | | } |
| | | } |