Commit 17856b4c authored by Lambertliu's avatar Lambertliu

Merge remote-tracking branch 'origin/develop_tzs_register_test' into develop_tzs_register_test

parents c714594f e29b6763
......@@ -166,127 +166,127 @@ public class EquipInfoCylinderExcelDto extends BaseDto {
private String inspectDate;
@ApiModelProperty(value = "检验报告编号")
@ExcelProperty(value = "检验报告编号")
@ExcelProperty(value = "检验报告编号", index = 28)
private String inspectReportNo;
//技术参数
@ExcelProperty(value = "额定质量(kg)", index = 28)
@ExcelProperty(value = "额定质量(kg)", index = 29)
@ApiModelProperty(value = "额定质量(kg)")
private String ratedQuality;
@ExcelProperty(value = "使用环境温度(℃)", index = 29)
@ExcelProperty(value = "使用环境温度(℃)", index = 30)
@ApiModelProperty(value = "使用环境温度(℃)")
private String ambientTemperature;
@ExcelProperty(value = "单瓶容积(m3)", index = 30)
@ExcelProperty(value = "单瓶容积(m3)", index = 31)
@ApiModelProperty(value = "单瓶容积(m3)")
@NotBlank(message = "单瓶容积(m3)不能为空")
private String singleBottleVolume;
@ExcelProperty(value = "型号", index = 31)
@ExcelProperty(value = "型号", index = 32)
@ApiModelProperty(value = "型号")
private String modelNumber;
@ExcelProperty(value = "充装介质", index = 32)
@ExcelProperty(value = "充装介质", index = 33)
@ApiModelProperty(value = "充装介质")
@NotBlank(message = "充装介质不能为空")
private String chargingMedium;
@ExcelProperty(value = "规格", index = 33)
@ExcelProperty(value = "规格", index = 34)
@ApiModelProperty(value = "规格")
private String specification;
@ExcelProperty(value = "外径", index = 34)
@ExcelProperty(value = "外径", index = 35)
@ApiModelProperty(value = "外径")
private String outsideDiameter;
@ExcelProperty(value = "壁厚", index = 35)
@ExcelProperty(value = "壁厚", index = 36)
@ApiModelProperty(value = "壁厚")
private String wallThickness;
@ExcelProperty(value = "长度", index = 36)
@ExcelProperty(value = "长度", index = 37)
@ApiModelProperty(value = "长度")
private String length;
@ExcelProperty(value = "公称工作压力(MPa)", index = 37)
@ExcelProperty(value = "公称工作压力(MPa)", index = 38)
@ApiModelProperty(value = "公称工作压力(MPa)")
@NotBlank(message = "公称工作压力(MPa)不能为空")
private String nominalWorkingPressure;
@ExcelProperty(value = "材料(管路)", index = 38)
@ExcelProperty(value = "材料(管路)", index = 39)
@ApiModelProperty(value = "材料(管路)")
private String piping;
@ExcelProperty(value = "无损检测方法(气瓶)", index = 39, converter = NondestructConverter.class)
@ExcelProperty(value = "无损检测方法(气瓶)", index = 40, converter = NondestructConverter.class)
@ApiModelProperty(value = "无损检测方法(气瓶)")
private String qpLossless;//5988
@ExcelProperty(value = "材料(瓶体)", index = 40)
@ExcelProperty(value = "材料(瓶体)", index = 41)
@ApiModelProperty(value = "材料(瓶体)")
private String bottleBody;
@ExcelProperty(value = "材料(端塞)", index = 41)
@ExcelProperty(value = "材料(端塞)", index = 42)
@ApiModelProperty(value = "材料(端塞)")
private String endPlug;
@ExcelProperty(value = "无损检测比例(管路)(%)", index = 42)
@ExcelProperty(value = "无损检测比例(管路)(%)", index = 43)
@ApiModelProperty(value = "无损检测比例(管路)(%)")
private String glRatio;
@ExcelProperty(value = "无损检测比例(气瓶)(%)", index = 43)
@ExcelProperty(value = "无损检测比例(气瓶)(%)", index = 44)
@ApiModelProperty(value = "无损检测比例(气瓶)(%)")
private String qpRatio;
@ExcelProperty(value = "无损检测方法(管路)", index = 44, converter = NondestructConverter.class)
@ExcelProperty(value = "无损检测方法(管路)", index = 45, converter = NondestructConverter.class)
@ApiModelProperty(value = "无损检测方法(管路)")
private String glLossless;
@ExcelProperty(value = "耐压实验压力(气瓶)(Mpa)", index = 45)
@ExcelProperty(value = "耐压实验压力(气瓶)(Mpa)", index = 46)
@ApiModelProperty(value = "耐压实验压力(气瓶)(Mpa)")
private String qpPressure;
@ExcelProperty(value = "耐压实验压力(管路)(Mpa)", index = 46)
@ExcelProperty(value = "耐压实验压力(管路)(Mpa)", index = 47)
@ApiModelProperty(value = "耐压实验压力(管路)(Mpa)")
private String glPressure;
@ExcelProperty(value = "气密性试验压力(气瓶)(Mpa)", index = 47)
@ExcelProperty(value = "气密性试验压力(气瓶)(Mpa)", index = 48)
@ApiModelProperty(value = "气密性试验压力(气瓶)(Mpa)")
private String qpAirTightness;
@ExcelProperty(value = "气体置换后压力(MPa)", index = 48)
@ExcelProperty(value = "气体置换后压力(MPa)", index = 49)
@ApiModelProperty(value = "气体置换后压力(MPa)")
private String displacementPressure;
@ExcelProperty(value = "热处理方式", index = 49)
@ExcelProperty(value = "热处理方式", index = 50)
@ApiModelProperty(value = "热处理方式")
private String heatTreatmentMethod;
@ExcelProperty(value = "气密性实验压力(管路)(MPa)", index = 50)
@ExcelProperty(value = "气密性实验压力(管路)(MPa)", index = 51)
@ApiModelProperty(value = "气密性实验压力(管路)(MPa)")
private String glAirTightness;
@ExcelProperty(value = "气瓶安装位置", index = 51)
@ExcelProperty(value = "气瓶安装位置", index = 52)
@ApiModelProperty(value = "气瓶安装位置")
private String installationPosition;
@ExcelProperty(value = "瓶体内含氧量(%)", index = 52)
@ExcelProperty(value = "瓶体内含氧量(%)", index = 53)
@ApiModelProperty(value = "瓶体内含氧量(%)")
private String oxygen;
@ExcelProperty(value = "热处理温度(℃)", index = 53)
@ExcelProperty(value = "热处理温度(℃)", index = 54)
@ApiModelProperty(value = "热处理温度(℃)")
private String qpHeatTreatmentTemperature;
/**
* 信息化管理字段-信息化管理情况
*/
@ExcelProperty(value = "信息化管理情况",index = 54, converter = InformationSituationConverter.class)
@ExcelProperty(value = "信息化管理情况", index = 55, converter = InformationSituationConverter.class)
private String informationSituation;
/**
* 信息化管理字段-二维码或者电子标签编号
*/
@ExcelProperty(value = "二维码或者电子标签编号",index = 55)
@ExcelProperty(value = "二维码或者电子标签编号", index = 56)
private String informationManageCode;
@ExcelIgnore
......
......@@ -74,7 +74,14 @@
AND isn.use_unit_credit_code = #{param.useUnitCreditCode}
</if>
<if test="param.orgBranchCode != null and param.orgBranchCode != ''">
AND isn.org_branch_code LIKE concat(#{param.orgBranchCode},'%')
<choose>
<when test="client == 'jgAudit'">
AND isn.org_branch_code= #{param.orgBranchCode}
</when>
<otherwise>
AND isn.org_branch_code LIKE concat(#{param.orgBranchCode},'%')
</otherwise>
</choose>
</if>
</if>
<if test="type == 'supervision'">
......
......@@ -266,7 +266,16 @@
AND use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
<choose>
<when test="client == 'jgAudit'">
and supervisionOrgCode = #{dto.orgBranchCode}
</when>
<otherwise>
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
</otherwise>
</choose>
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
......
......@@ -43,8 +43,14 @@
and tjvi.use_unit_credit_code = #{dto.useUnitCreditCode}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
and tjvi.org_branch_code like concat(#{dto.orgBranchCode}, '%')
</if>
<choose>
<when test="client == 'jgAudit'">
and tjvi.org_branch_code = #{dto.orgBranchCode}
</when>
<otherwise>
and tjvi.org_branch_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
</otherwise>
</choose> </if>
</where>
order by
<if test="sort != null">
......
......@@ -5,10 +5,9 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiParam;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -154,8 +153,27 @@ public class DataHandlerController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "使用登记、车用气瓶登记历史单据使用登记表生成", notes = "使用登记、车用气瓶登记历史单据使用登记表生成")
@GetMapping(value = "/initFormUrl")
public void initFormUrl() {
public ResponseModel<Boolean> initFormUrl() {
dataHandlerService.initFormUrl();
ResponseHelper.buildResponse(true);
return ResponseHelper.buildResponse(Boolean.TRUE);
}
/**
* 同步设备信息到ES
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "同步设备信息到ES", notes = "同步设备信息到ES")
@PostMapping(value = "/synchronizeEqData2ES")
public ResponseModel<String> synchronizeEqData2ES(@ApiParam(value = "设备的record,多个设备使用英文逗号分割", required = true)
@RequestParam(value = "records") String records,
@ApiParam(value = "是否安改维单位,默认值'false'", required = true, defaultValue = "false")
@RequestParam(value = "isAgw", defaultValue = "false") Boolean isAgw,
@ApiParam(value = "是否纳管,默认值'true'", required = true, defaultValue = "true")
@RequestParam(value = "isIntoManagement", defaultValue = "true") Boolean isIntoManagement) {
StopWatch watch = new StopWatch();
watch.start();
dataHandlerService.synchronizeEqData2ES(records, isAgw, isIntoManagement);
watch.stop();
return ResponseHelper.buildResponse(String.format("同步成功,耗时:%s", watch.getTotalTimeSeconds()));
}
}
......@@ -252,7 +252,18 @@ public class SafetyProblemTracingController extends BaseController {
return ResponseHelper.buildResponse("success");
}
/**
* test3
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "生成维保超期数据", notes = "生成维保超期数据")
@GetMapping(value = "/gen/test4")
public ResponseModel<String> test4() {
safetyProblemTracingGenService.executePersonnalCertificationCheck();
return ResponseHelper.buildResponse("success");
}
/**
* update3 -- 修复
*
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -9,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
......@@ -18,6 +21,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PieLineEquipContraptionDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.DataHandlerMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
......@@ -42,12 +46,14 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE_NAME;
......@@ -84,6 +90,8 @@ public class DataHandlerServiceImpl {
private final IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
private final JgInstallationNoticeMapper jgInstallationNoticeMapper;
private final DataHandlerMapper dataHandlerMapper;
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
;
/**
......@@ -986,4 +994,39 @@ public class DataHandlerServiceImpl {
jgVehicleInformationService.initFormUrl();
useRegistrationService.initFormUrl();
}
public void synchronizeEqData2ES(String records, Boolean isAgw, Boolean isIntoManagement) {
if (records == null || records.isEmpty()) {
return;
}
String[] recordArr = records.trim().split(",");
for (String record : recordArr) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record);
categoryOtherInfoMapper.updateEsStatus(record);
ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(record);
if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(record);
}
if (!ObjectUtils.isEmpty(dto)) {
long time = Timestamp.valueOf(map.get("REC_DATE").toString().substring(0, 19)).getTime();
dto.setREC_DATE(time);
// 需要安装的设备 安装告知审批通过 清除设备的USC_UNIT_CREDIT_CODE安装单位信息
// 使用单位编辑 防止更新设备时将安改维单位信息更新到es中
if (!isAgw) {
dto.setUSC_UNIT_CREDIT_CODE(null);
dto.setUSC_UNIT_NAME(null);
}
if (map.get("NEXT_INSPECT_DATE") != null) {
Date nextInspectDate = (Date) map.get("NEXT_INSPECT_DATE");
dto.setNEXT_INSPECT_DATE(DateUtil.parse(DateUtil.format(nextInspectDate, DatePattern.NORM_DATE_PATTERN)).getTime());
}
dto.setIS_INTO_MANAGEMENT(isIntoManagement);
IdxBizJgUseInfo useInfo = useInfoService.lambdaQuery().eq(IdxBizJgUseInfo::getRecord, record).one();
dto.setUSE_PLACE_CODE(useInfo.getProvince() + "#" + useInfo.getCity() + "#" + useInfo.getCounty() + "#" + useInfo.getFactoryUseSiteStreet());
dto.setUSE_SITE_CODE(useInfo.getUsePlace());
esEquipmentCategory.save(dto);
}
}
}
}
......@@ -199,7 +199,7 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
.eq(!ValidationUtil.isEmpty(equCategory), IdxBizJgProjectContraption::getEquCategory, equCategory)
.eq(!ValidationUtil.isEmpty(equDefine), IdxBizJgProjectContraption::getEquDefine, equDefine)
.like(!ValidationUtil.isEmpty(projectContraption), IdxBizJgProjectContraption::getProjectContraption, projectContraption)
.like(!ValidationUtil.isEmpty(orgBranchCode), IdxBizJgProjectContraption::getOrgCode, orgBranchCode)
.eq(!ValidationUtil.isEmpty(orgBranchCode), IdxBizJgProjectContraption::getOrgCode, orgBranchCode)
.like(!ValidationUtil.isEmpty(projectContraptionNo), IdxBizJgProjectContraption::getProjectContraptionNo, projectContraptionNo)
.isNull(!ValidationUtil.isEmpty(regCodeIsNull) && Boolean.TRUE.equals(Boolean.valueOf(regCodeIsNull)), IdxBizJgProjectContraption::getUseRegistrationCode)
.isNotNull(!ValidationUtil.isEmpty(regCodeIsNull) && Boolean.FALSE.equals(Boolean.valueOf(regCodeIsNull)), IdxBizJgProjectContraption::getUseRegistrationCode)
......
......@@ -2588,7 +2588,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 增加监管端查询, 查询规则看到本级及之下的设备
if(!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))){
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(map.getString("ORG_BRANCH_CODE")) + "*"));
boolMust.must(QueryBuilders.termQuery("ORG_BRANCH_CODE.keyword", map.getString("ORG_BRANCH_CODE")));
}
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
......
......@@ -2118,6 +2118,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jsonObject.put("receiveOrgCode", jgUseRegistration.getReceiveCompanyCode() + "_" + jgUseRegistration.getReceiveOrgName());
jsonObject.put("status", jgUseRegistration.getStatus());
jsonObject.put("applyNo", jgUseRegistration.getApplyNo());
jsonObject.put("installAddress", jsonObject.getString("address"));// 前端展示填充数据
Optional.ofNullable(jsonObject.get("safetyManagerName")).ifPresent(name -> jsonObject.put("maintenanceManagerName", name));
Optional.ofNullable(jsonObject.get("phone")).ifPresent(phone -> jsonObject.put("maintenanceManagerPhone", phone));
jsonObject.remove("submit");
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -65,11 +66,17 @@ public class SafetyProblemTracingGenServiceImpl{
public void executeSafetyProblemCheck() {
executeMaintenanceCheck();
executeInspectionCheck();
executePersonnalCertificationCheck();
executeEnterpriseQualificationCheck();
}
private void executePersonnalCertificationCheck() {
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "executePersonnalCertification", lockAtMostFor = "PT5H", lockAtLeastFor = "PT10M")
public void executePersonnalCertification() {
executePersonnalCertificationCheck();
}
public void executePersonnalCertificationCheck() {
logger.info("开始人员资质超期检查");
List<Map<String, Object>> certificationRecords = commonMapper.queryOutOfCertificationRecord();
updateUserInfoAndSendMessage(certificationRecords);
......@@ -181,11 +188,13 @@ public class SafetyProblemTracingGenServiceImpl{
*/
private void sendSafetyProblemMessage(List<Map<String, Object>> mapList, SafetyProblemTypeEnum safetyProblemTypeEnum) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(mapList));
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
throw new RuntimeException(e);
if (CollectionUtil.isNotEmpty(jsonArray)){
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
throw new RuntimeException(e);
}
}
}
}
\ No newline at end of file
......@@ -2538,60 +2538,112 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*
* @param paramMap 更新的参数
*/
@Override
// @Override
// public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
// if (paramMap.isEmpty()) {
// return null;
// }
// String oldUscUnitCreditCode = "";
// String oldUscUnitName = "";
// 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();
// oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
// oldUscUnitName = oldData.getUSC_UNIT_NAME();
// }
// // 获取Es中新的参数
// ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
// String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
// String newUscUnitName = newData.getUSC_UNIT_NAME();
//
// // 删除Es中旧的数据
// if (!ObjectUtils.isEmpty(oldData)) {
// esEquipmentCategory.deleteById(record);
// // 整合新旧数据
// Bean.copyExistPropertis(newData, oldData);
// // 处理施工单位信息[去重]
// if (!ValidationUtil.isEmpty(newUscUnitCreditCode)) {
// // if (!ValidationUtil.isEmpty(oldUscUnitCreditCode)) {
// // if (!oldUscUnitCreditCode.contains(newUscUnitCreditCode)) {
// // oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
// // oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
// // }
// // } else {
// oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
// oldData.setUSC_UNIT_NAME(newUscUnitName);
// // }
// }
//
// }
// if (!ObjectUtils.isEmpty(oldData)) {
// oldData.setREC_DATE(System.currentTimeMillis());
// ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
//
// // 组装返回数据
// resultMap.put(record, saveData);
// }
// }
//
// }
// return resultMap;
// }
@Override
public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
if (paramMap.isEmpty()) {
return null;
}
String oldUscUnitCreditCode = "";
String oldUscUnitName = "";
Map<String, Object> resultMap = new HashMap<>();
Map<String, ESEquipmentCategoryDto> oldDataMap = new HashMap<>();
List<ESEquipmentCategoryDto> saveList = new ArrayList<>();
// 批量获取旧数据
for (String record : paramMap.keySet()) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
optional.ifPresent(dto -> oldDataMap.put(record, dto));
}
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();
oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
oldUscUnitName = oldData.getUSC_UNIT_NAME();
}
// 获取Es中新的参数
ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
String newUscUnitName = newData.getUSC_UNIT_NAME();
// 删除Es中旧的数据
if (!ObjectUtils.isEmpty(oldData)) {
esEquipmentCategory.deleteById(record);
// 整合新旧数据
ESEquipmentCategoryDto oldData = oldDataMap.get(record);
ESEquipmentCategoryDto newData = JSON.parseObject(JSON.toJSONString(childMap), ESEquipmentCategoryDto.class);
if (oldData != null) {
Bean.copyExistPropertis(newData, oldData);
// 处理施工单位信息[去重]
String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
String newUscUnitName = newData.getUSC_UNIT_NAME();
if (!ValidationUtil.isEmpty(newUscUnitCreditCode)) {
// if (!ValidationUtil.isEmpty(oldUscUnitCreditCode)) {
// if (!oldUscUnitCreditCode.contains(newUscUnitCreditCode)) {
// oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
// oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
// }
// } else {
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
// }
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
}
}
if (!ObjectUtils.isEmpty(oldData)) {
oldData.setREC_DATE(System.currentTimeMillis());
ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
// 组装返回数据
resultMap.put(record, saveData);
saveList.add(oldData);
}
}
}
// 批量删除旧数据
esEquipmentCategory.deleteAll(oldDataMap.values());
// 批量保存新数据
Iterable<ESEquipmentCategoryDto> savedData = esEquipmentCategory.saveAll(saveList);
// 组装返回数据
Map<String, Object> resultMap = new HashMap<>();
savedData.forEach(dto -> resultMap.put(dto.getSEQUENCE_NBR(), dto));
return resultMap;
}
......
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