Commit c269cb3e authored by 韩桐桐's avatar 韩桐桐

fix(jg):BUG 25390

parent d3eca9d7
......@@ -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()));
}
}
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);
}
}
}
}
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