lin
2024-03-25 9f8f9d13c42ca8cdccbf351069082a5fdccef2e4
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -46,6 +46,7 @@
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;
@@ -227,11 +228,49 @@
   private void savePlacePractitioner(PlaceVO placeVO) {
      if (placeVO.getPlacePractitioner() != null) {
         IPlacePractitionerService practitionerService = SpringUtil.getBean(IPlacePractitionerService.class);
         List<PlacePractitionerEntity> placePractitioner = placeVO.getPlacePractitioner();
         for (PlacePractitionerEntity placePractitionerEntity : placePractitioner) {
         // 查询对应已存在的租户
         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());
         }
         practitionerService.saveOrUpdateBatch(placeVO.getPlacePractitioner());
         // 申明新增,修改,删除集合
         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);
         }
      }
   }
@@ -261,6 +300,7 @@
    *
    * @param placeVO
    */
   @Override
   public void jwGridCodeBind(PlaceVO placeVO) {
      if (!Strings.isBlank(placeVO.getLng())) {
         String point = "'POINT(" + placeVO.getLng() + " " + placeVO.getLat() + ")'";
@@ -494,7 +534,8 @@
    *
    * @param placeVO
    */
   private void policePositionHandle(PlaceVO placeVO) {
   @Override
   public void policePositionHandle(PlaceVO placeVO) {
      // 是民警且位置信息存在
      if (!Strings.isBlank(placeVO.getLng())) {
         //点坐标解析