Commit e3443191 authored by tianbo's avatar tianbo

修改一码通es初始化接口

parent ab78a817
......@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.tzs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.api.entity.SuperviseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 特种设备基本信息-监督管理信息 Mapper 接口
......@@ -11,4 +14,5 @@ import com.yeejoin.amos.boot.module.tzs.api.entity.SuperviseInfo;
*/
public interface SuperviseInfoMapper extends BaseMapper<SuperviseInfo> {
void updateRecordBatch(@Param("recordList") List<String> recordList);
}
......@@ -60,10 +60,6 @@
AND use_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.useCode},'%')
</if>
<if
test="tzBaseEnterpriseInfoDto.superviseOrgCode!=null and tzBaseEnterpriseInfoDto.superviseOrgCode!='' ">
AND supervise_org_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.superviseOrgCode},'%')
</if>
<if
test="tzBaseEnterpriseInfoDto.region!=null and tzBaseEnterpriseInfoDto.region!='' ">
AND CONCAT(province,'/',city,'/',district) LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.region},'%')
</if>
......@@ -115,10 +111,6 @@
AND use_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.useCode},'%')
</if>
<if
test="tzBaseEnterpriseInfoDto.superviseOrgCode!=null and tzBaseEnterpriseInfoDto.superviseOrgCode!='' ">
AND supervise_org_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.superviseOrgCode},'%')
</if>
<if
test="tzBaseEnterpriseInfoDto.region!=null and tzBaseEnterpriseInfoDto.region!='' ">
AND CONCAT(province,'/',city,'/',district) LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.region},'%')
</if>
......@@ -136,7 +128,7 @@
</if>
<if
test="tzBaseEnterpriseInfoDto.address!=null and tzBaseEnterpriseInfoDto.address!='' ">
AND supervise_org_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.address},'%')
AND address LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.address},'%')
</if>
<if test="tzBaseEnterpriseInfoDto.regulatoryLabels!=null and tzBaseEnterpriseInfoDto.regulatoryLabels!='' ">
AND regulatory_labels LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.regulatoryLabels},'%')
......
......@@ -319,8 +319,9 @@ public class EquipmentCategoryController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/test")
@ApiOperation(httpMethod = "GET", value = "test", notes = "test")
public void test() {
public ResponseModel<String> test() {
equipmentCategoryServiceImpl.saveEs();
return ResponseHelper.buildResponse("success");
}
......
......@@ -6,17 +6,26 @@ import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.*;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategoryData;
import com.yeejoin.amos.boot.module.tzs.api.entity.SuperviseInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.SupervisoryCodeInfo;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.tzs.api.mapper.*;
import com.yeejoin.amos.boot.module.tzs.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryDataMapper;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tzs.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.boot.module.tzs.api.mapper.SupervisoryCodeInfoMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.tzs.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.biz.utils.JsonUtils;
......@@ -24,7 +33,6 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.PrivilegeFeginService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
......@@ -50,13 +58,23 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.stream.Collectors;
/**
......@@ -76,6 +94,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private SuperviseInfoMapper superviseInfoMapper;
@Autowired
private SuperviseInfoService superviseInfoService;
@Autowired
EquipmentCategoryMapper equipmentCategoryMapper;
@Value("classpath:/json/equipCategory.json")
......@@ -853,7 +874,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public Page<Map<String, Object>> getAll(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
String selectSql = " SELECT * FROM " + tableName;
String selectSql = " SELECT * FROM " + tableName + " WHERE IS_NOT_ES <> 1 or IS_NOT_ES IS NULL ";
Integer number = ValidationUtil.isEmpty(map.get("number")) ? 0 : Integer.valueOf(map.get("number").toString());
Integer size = ValidationUtil.isEmpty(map.get("size")) ? 0 : Integer.valueOf(map.get("size").toString());
Page<Map<String, Object>> page = new Page<>(number, size);
......@@ -870,7 +891,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
String countSql = " SELECT COUNT(SEQUENCE_NBR) count FROM " + tableName;
String countSql = " SELECT COUNT(SEQUENCE_NBR) count FROM " + tableName + " WHERE IS_NOT_ES <> 1 or IS_NOT_ES IS NULL";
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count;
}
......@@ -893,13 +914,45 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
map.put("number", i);
map.put("size", 1000);
Page<Map<String, Object>> page = getAll(map);
for (Map<String, Object> record : page.getRecords()) {
if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
saveESEquipmentCategory(record);
saveBatchEquipment2Es(page.getRecords());
// for (Map<String, Object> record : page.getRecords()) {
// if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
// saveESEquipmentCategory(record);
// }
// }
}
}
public void saveBatchEquipment2Es(List<Map<String, Object>> equipList) {
List<ESEquipmentCategoryDto> esEquipDtoList = Lists.newArrayList();
List<String> recordList = Lists.newArrayList();
if (ValidationUtil.isEmpty(equipList)) {
return;
}
for (Map<String, Object> e : equipList) {
String recDate1 = "";
if (ValidationUtil.isEmpty(e.get("REC_DATE"))) {
try {
recDate1 = DateUtil.formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
recDate1 = e.get("REC_DATE").toString().substring(0, 19);
}
long time = Timestamp.valueOf(recDate1).getTime();
e.put("REC_DATE", time);
ESEquipmentCategoryDto esEquipDto = JSONObject.parseObject(JSONObject.toJSONString(e),
ESEquipmentCategoryDto.class);
esEquipDtoList.add(esEquipDto);
recordList.add((String) e.get("SEQUENCE_NBR"));
}
esEquipmentCategory.saveAll(esEquipDtoList);
superviseInfoMapper.updateRecordBatch(recordList);
}
/**
* es保存设备数据
*/
......
......@@ -287,6 +287,10 @@ public class UnitInfoController extends BaseController {
flag = true;
}
}
// “超级验证码",压测使用
if ("88888888".equals(code)) {
flag = true;
}
return ResponseHelper.buildResponse(flag);
}
......
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