From 401feb9c87b309a4f2412abe15e3e9be56378e71 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Mon, 18 Mar 2024 17:10:50 +0800
Subject: [PATCH] 场所从业人员新增修改处理修改,详情查询修改
---
src/main/java/org/springblade/modules/place/entity/PlaceEntity.java | 4 +-
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java | 45 +++++++++++++++++++++-
src/main/java/org/springblade/modules/place/entity/PlacePractitionerEntity.java | 21 ----------
src/main/java/org/springblade/modules/place/mapper/PlaceMapper.xml | 1
4 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/src/main/java/org/springblade/modules/place/entity/PlaceEntity.java b/src/main/java/org/springblade/modules/place/entity/PlaceEntity.java
index 147b2a9..5d65272 100644
--- a/src/main/java/org/springblade/modules/place/entity/PlaceEntity.java
+++ b/src/main/java/org/springblade/modules/place/entity/PlaceEntity.java
@@ -195,8 +195,8 @@
@TableField("aoi_code")
private String aoiCode;
- /** 1:否 2:是 三级消防单位 */
- @ApiModelProperty(value = "1:否 2:是 三级消防单位", example = "")
+ /** 1:是 2:否 三级消防单位 */
+ @ApiModelProperty(value = "1:是 2:否 三级消防单位", example = "")
@TableField("three_fire_protection")
private Integer threeFireProtection;
diff --git a/src/main/java/org/springblade/modules/place/entity/PlacePractitionerEntity.java b/src/main/java/org/springblade/modules/place/entity/PlacePractitionerEntity.java
index 4bd0493..cd03bd5 100644
--- a/src/main/java/org/springblade/modules/place/entity/PlacePractitionerEntity.java
+++ b/src/main/java/org/springblade/modules/place/entity/PlacePractitionerEntity.java
@@ -1,31 +1,10 @@
-/*
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the dreamlu.net developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: Chill 庄骞 (smallchill@163.com)
- */
package org.springblade.modules.place.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-import lombok.EqualsAndHashCode;
-import org.springblade.core.tenant.mp.TenantEntity;
-
import java.io.Serializable;
import java.util.Date;
diff --git a/src/main/java/org/springblade/modules/place/mapper/PlaceMapper.xml b/src/main/java/org/springblade/modules/place/mapper/PlaceMapper.xml
index e2d80b1..346f384 100644
--- a/src/main/java/org/springblade/modules/place/mapper/PlaceMapper.xml
+++ b/src/main/java/org/springblade/modules/place/mapper/PlaceMapper.xml
@@ -344,6 +344,7 @@
jp.is_front,
jp.front_type,
jp.remark,
+ jp.three_fire_protection,
bu.real_name as username,bu.phone as phone,
jppl.id as plid,
jppl.place_id,
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 91c24b1..33dec6f 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
@@ -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);
+ }
}
}
--
Gitblit v1.9.3