Commit 6304adbd authored by 赵啸非's avatar 赵啸非

修改区域批量更新

parent dac3a5dc
...@@ -131,6 +131,17 @@ public class BaseAreaServiceImpl extends AbstractCRUDServiceImpl<BaseAreaDao, Ba ...@@ -131,6 +131,17 @@ public class BaseAreaServiceImpl extends AbstractCRUDServiceImpl<BaseAreaDao, Ba
} }
private BaseAreaEntity updateAndSaveEntity(BaseAreaQuery baseAreaQuery, GroupAreaInfo group) { private BaseAreaEntity updateAndSaveEntity(BaseAreaQuery baseAreaQuery, GroupAreaInfo group) {
BaseAreaEntity entity = new BaseAreaEntity();
entity.initAttrValue();
BeanUtils.copyProperties(group, entity, BeanUtil.getNullPropertyNames(group));
entity.setName(group.getShortName());
entity.setCreateTime(new Date());
entity.setCreateUserId(1L);
entity.setUpdateTime(new Date());
entity.setStatus(1);
/*
BaseAreaEntity entity = this.selectOne(baseAreaQuery); BaseAreaEntity entity = this.selectOne(baseAreaQuery);
if (ObjectUtils.isEmpty(entity)) { if (ObjectUtils.isEmpty(entity)) {
//新增 //新增
...@@ -151,7 +162,7 @@ public class BaseAreaServiceImpl extends AbstractCRUDServiceImpl<BaseAreaDao, Ba ...@@ -151,7 +162,7 @@ public class BaseAreaServiceImpl extends AbstractCRUDServiceImpl<BaseAreaDao, Ba
entity.setUpdateTime(new Date()); entity.setUpdateTime(new Date());
// this.update(entity); // this.update(entity);
} }
*/
return entity; return entity;
} }
......
...@@ -15,6 +15,7 @@ import com.mortals.xhx.common.keys.RedisCacheKeys; ...@@ -15,6 +15,7 @@ import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.base.model.BaseAreaEntity; import com.mortals.xhx.module.base.model.BaseAreaEntity;
import com.mortals.xhx.module.base.model.BaseAreaQuery; import com.mortals.xhx.module.base.model.BaseAreaQuery;
import com.mortals.xhx.module.base.service.BaseAreaService; import com.mortals.xhx.module.base.service.BaseAreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -35,6 +36,7 @@ import java.util.stream.Collectors; ...@@ -35,6 +36,7 @@ import java.util.stream.Collectors;
*/ */
@RestController @RestController
@RequestMapping("base/area") @RequestMapping("base/area")
@Slf4j
public class BaseAreaController extends BaseCRUDJsonBodyMappingController<BaseAreaService, BaseAreaEntity, Long> { public class BaseAreaController extends BaseCRUDJsonBodyMappingController<BaseAreaService, BaseAreaEntity, Long> {
@Autowired @Autowired
...@@ -120,15 +122,22 @@ public class BaseAreaController extends BaseCRUDJsonBodyMappingController<BaseAr ...@@ -120,15 +122,22 @@ public class BaseAreaController extends BaseCRUDJsonBodyMappingController<BaseAr
List<BaseAreaEntity> list = new ArrayList<>(); List<BaseAreaEntity> list = new ArrayList<>();
this.service.updateArea(areaQuery, list, getContext()); this.service.updateArea(areaQuery, list, getContext());
log.info("保存基础区域数据,共{}条", list.size());
if (!ObjectUtils.isEmpty(list)) {
Lists.partition(list, 500).forEach(item -> this.service.save(item));
}
/*
Map<Boolean, List<BaseAreaEntity>> collect = list.stream().collect(Collectors.partitioningBy(x -> x.getId() == null)); Map<Boolean, List<BaseAreaEntity>> collect = list.stream().collect(Collectors.partitioningBy(x -> x.getId() == null));
List<BaseAreaEntity> saveList = collect.get(true); List<BaseAreaEntity> saveList = collect.get(true);
if (!ObjectUtils.isEmpty(saveList)) { if (!ObjectUtils.isEmpty(saveList)) {
Lists.partition(saveList, 100).forEach(item -> this.service.save(item)); Lists.partition(saveList, 100).forEach(item -> this.service.save(item));
} }*/
List<BaseAreaEntity> updateList = collect.get(false); /* List<BaseAreaEntity> updateList = collect.get(false);
if (!ObjectUtils.isEmpty(updateList)) { if (!ObjectUtils.isEmpty(updateList)) {
Lists.partition(updateList, 100).forEach(item -> this.service.update(item)); Lists.partition(updateList, 100).forEach(item -> this.service.update(item));
} }*/
}).start(); }).start();
//编码优先 //编码优先
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment