Commit 3646b4c8 authored by liufan's avatar liufan

添加:更新ES数据的公共方法

parent 5ce89779
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.ymt.api.service; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.ymt.api.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -43,4 +44,6 @@ public interface IEquipmentCategoryService { ...@@ -43,4 +44,6 @@ public interface IEquipmentCategoryService {
ResponseModel submit(Map<String, Object> map); ResponseModel submit(Map<String, Object> map);
void creatXiXian(String type); void creatXiXian(String type);
Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap);
} }
...@@ -98,6 +98,7 @@ import org.springframework.util.Assert; ...@@ -98,6 +98,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateUtil; import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
...@@ -2452,4 +2453,45 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2452,4 +2453,45 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
return true; return true;
} }
/**
* 更新ES中的数据(公共方法)
* @param paramMap 更新的参数
*/
public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap){
if(paramMap.isEmpty()){
return null;
}
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<String, Map<String, Object>> entry : paramMap.entrySet()) {
String record = entry.getKey();
Map<String, Object> childMap = entry.getValue();
if(!childMap.isEmpty()){
ESEquipmentCategoryDto oldData = null;
//获取Es中旧的数据
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if(!ObjectUtils.isEmpty(optional)){
oldData = optional.get();
}
//获取Es中新的参数
ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
//删除Es中旧的数据
if (!ObjectUtils.isEmpty(oldData)) {
esEquipmentCategory.deleteById(record);
//整合新旧数据
Bean.copyExistPropertis(newData, oldData);
}
if (!ObjectUtils.isEmpty(oldData)) {
oldData.setREC_DATE(System.currentTimeMillis());
ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
//组装返回数据
resultMap.put(record,saveData);
}
}
}
return resultMap;
}
} }
\ No newline at end of file
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