| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.pro.packaged.W; |
| | | 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.param.CommonParamSet; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | 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.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.service.*; |
| | | import org.springblade.modules.place.vo.PlaceCheckVO; |
| | | 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.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | |
| | | |
| | | @Autowired |
| | | private IPlaceRelService placeRelService; |
| | | |
| | | @Autowired |
| | | private IPlaceDoorService placeDoorService; |
| | | |
| | | @Autowired |
| | | private IDoorplateAddressService doorplateAddressService; |
| | |
| | | if (null != one) { |
| | | placeVO.setId(one.getId()); |
| | | } else { |
| | | // 扫码来的默认绑定本身 |
| | | placeVO.setHouseCodeBinds(placeVO.getHouseCode()); |
| | | // 新增,地址表中没有或者地址表中有场所表中没有的(是房屋的),扫码进来的 |
| | | save(placeVO); |
| | | } |
| | |
| | | bindUserHandle(placeVO); |
| | | // 设置完善状态 |
| | | setPlaceStatus(placeVO); |
| | | // 房屋编号绑定处理 |
| | | houseCodeBindHandle(placeVO); |
| | | // 更新场所信息 |
| | | flag = updateById(placeVO); |
| | | } else { |
| | |
| | | // 新增场所信息 |
| | | flag = save(placeVO); |
| | | } |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | placeVO.setRoleName(roleName); |
| | | // 保存场所详情及任务信息 |
| | | savePlaceExtAndTaskInfo(placeVO); |
| | | // 场所标签信息绑定(更新,调整) |
| | | placeLabelBind(placeVO); |
| | | // 网格绑定 |
| | | gridBind(placeVO); |
| | | // 网格编号绑定场所-新 |
| | | gridCodeBind(placeVO); |
| | | // 警务网格绑定 |
| | | jwGridCodeBind(placeVO); |
| | | // 房屋编号绑定 |
| | | // houseCodeBind(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) { |
| | | 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); |
| | |
| | | removeById(one.getId()); |
| | | } |
| | | } |
| | | if (longs.size() > 0) { |
| | | // 删除对应的详情 |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | } |
| | | } else { |
| | | // 一对一,暂时不处理,后续考虑需加绑定关系表 |
| | | } |
| | | if (longs.size() > 0) { |
| | | // 删除对应的详情 |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | // 删除对应的场所门牌绑定关系信息 |
| | | removePlaceDoor(longs); |
| | | } |
| | | } |
| | | |
| | |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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()); |
| | |
| | | // 新增 |
| | | 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); |
| | | } |
| | |
| | | if (null != grid && !Strings.isBlank(grid.getGridCode())) { |
| | | // 场所编号绑定 |
| | | placeVO.setGridCode(grid.getGridCode()); |
| | | placeVO.setGridId(grid.getId()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 民警角色位置绑定 |
| | | * 其他角色时位置绑定 |
| | | * |
| | | * @param placeVO |
| | | */ |
| | | private 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()); |
| | |
| | | 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); |
| | | } |
| | |
| | | if (null != gridEntity && !Strings.isBlank(gridEntity.getGridCode())) { |
| | | // 场所编号绑定 |
| | | placeVO.setGridCode(gridEntity.getGridCode()); |
| | | placeVO.setGridId(gridEntity.getId()); |
| | | // 更新场所信息 |
| | | updateById(placeVO); |
| | | } |
| | |
| | | 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()); |
| | |
| | | removePlaceExt(longs); |
| | | // 删除对应的标签绑定信息 |
| | | removePlaceLabel(longs); |
| | | // 删除对应的门牌绑定信息 |
| | | removePlaceDoor(longs); |
| | | // 返回 |
| | | return removeByIds; |
| | | } |
| | |
| | | QueryWrapper<PlacePoiLabel> wrapper = new QueryWrapper<>(); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | 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; |
| | | } |
| | | } |