| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |