Commit 26b6d2fc authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://39.100.92.250:5000/moa/amos-boot-biz into develop_tzs_register
parents 6c6581f4 fa9ffc12
......@@ -128,7 +128,7 @@
<dependency>
<groupId>cn.com.vastdata</groupId>
<artifactId>vastbase-jdbc</artifactId>
<version>2.10p</version>
<version>2.12p</version>
</dependency>
<dependency>
<groupId>com.olym</groupId>
......
......@@ -70,6 +70,11 @@ public class DPFilterParamForDetailDto {
private String superviseUnitName;
/**
* 监管单位名称(接收单位/管辖机构)
*/
private String orgBranchCode;
/**
* 企业单位名称(发起单位/使用单位)
*/
private String companyName;
......
package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* @author LiuLin
*/
public interface CustomBaseMapper<T> extends BaseMapper<T> {
Integer insertBatchSomeColumn(List<T> entityList);
/**
* 分批批量插入
* @param entityList 数据集合
* @param batchSize 每批数量
* @return 插入总条数
*/
default int insertBatchSomeColumn(List<T> entityList, int batchSize) {
if (entityList == null || entityList.isEmpty()) {
return 0;
}
int total = 0;
for (int i = 0; i < entityList.size(); i += batchSize) {
int endIndex = Math.min(i + batchSize, entityList.size());
List<T> subList = entityList.subList(i, endIndex);
total += insertBatchSomeColumn(subList);
}
return total;
}
}
......@@ -78,6 +78,7 @@ public class TZSCommonServiceImpl {
String nearStr = licensesStatusMap.get(near);
String normalStr = licensesStatusMap.get(normal);
String noneStr = licensesStatusMap.get(none);
String noLicenseStr = licensesStatusMap.get(noLicense);
if (!ObjectUtils.isEmpty(licenses)) {
if (!"".equals(licensesStatusStr)) {
licensesStatus = licensesStatusMap.get(licensesStatusStr);
......@@ -85,6 +86,10 @@ public class TZSCommonServiceImpl {
List<String> permissionStatusList = new ArrayList<>();
for (Object object : licenses) {
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(object));
if(!json.containsKey("certNo")){
permissionStatusList.add(noLicenseStr);
continue;
}
if (!json.containsKey("expiryDate")) {
permissionStatusList.add(noneStr);
continue;
......@@ -101,23 +106,26 @@ public class TZSCommonServiceImpl {
}
}
}
long cq = permissionStatusList.stream().filter(e -> e.equals(overdueStr)).count();
long lq = permissionStatusList.stream().filter(e -> e.equals(nearStr)).count();
long no = permissionStatusList.stream().filter(e -> e.equals(noneStr)).count();
long zc = permissionStatusList.stream().filter(e -> e.equals(normalStr)).count();
// 需按照资质严重顺序进行判断,先判断超期,再判断临期,再判断无有效期,最后判断正常
if (cq > 0) {
long overdue = permissionStatusList.stream().filter(e -> e.equals(overdueStr)).count();
long near = permissionStatusList.stream().filter(e -> e.equals(nearStr)).count();
long no = permissionStatusList.stream().filter(e -> e.equals(noLicenseStr)).count();
long none = permissionStatusList.stream().filter(e -> e.equals(noneStr)).count();
long normal = permissionStatusList.stream().filter(e -> e.equals(normalStr)).count();
// 需按照资质严重顺序进行判断,先判断超期,再判断临期,在判断无资质,再判断无有效期,最后判断正常
if (overdue > 0) {
licensesStatus = overdueStr;
} else if (lq > 0) {
} else if (near > 0) {
licensesStatus = nearStr;
} else if (no > 0) {
licensesStatus = noLicenseStr;
} else if (none > 0) {
licensesStatus = noneStr;
} else if (zc > 0) {
} else if (normal > 0) {
licensesStatus = normalStr;
}
}
} else {
licensesStatus = licensesStatusMap.get(noLicense);
licensesStatus = noLicenseStr;
}
} else {
licensesStatus = !"".equals(licensesStatusStr) ? licensesStatusMap.get(licensesStatusStr) : licensesStatusMap.get(noLicenseReq);
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.jg.api.converter.*;
import io.swagger.annotations.ApiModel;
......@@ -284,5 +285,5 @@ public class EquipInfoCylinderExcelDto extends BaseDto {
private String informationManageCode;
@ExcelIgnore
private List fileData;
private List<?> fileData;
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.Collection;
import java.util.List;
/**
* @author DELL
*/
public interface CustomBaseMapper<T> extends BaseMapper<T> {
Integer insertBatchSomeColumn(List<T> entityList);
}
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationUnitEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationUnit;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransferEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgEquipTransferDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransfer;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
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.JgInstallationNoticeEq;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgNoticeToBeSubmitDto;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintainNoticeEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgMaintainNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintainNotice;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq;
import org.apache.ibatis.annotations.Param;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNoticeEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgReformNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNotice;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNoticeEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgTransferNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNotice;
......
......@@ -53,7 +53,7 @@
<dependency>
<groupId>cn.com.vastdata</groupId>
<artifactId>vastbase-jdbc</artifactId>
<version>2.10p</version>
<version>2.12p</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
......
......@@ -285,7 +285,6 @@ public class IdxBizJqEquipmentRegisterController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/importData")
@ApiOperation(httpMethod = "POST", value = "气瓶批量导入", notes = "气瓶批量导入")
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<?> importPressureData(@RequestPart("file") MultipartFile multipartFile) throws Exception {
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.importPressureData(multipartFile));
}
......
......@@ -60,9 +60,10 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
List<FieldChangeMeta> allChangeColumns = new ArrayList<>();
List<PipelineChangeItemDto> items = insertOrEditPieLines.toJavaList(PipelineChangeItemDto.class);
// 1.设备技术参数入库前校验,约束:同一个装置下的管道编号不能重复
if (items.size() != items.stream().map(TechParamsPipelineChangeFieldDto::getPipelineNumber).distinct().count()) {
throw new BadRequest("同一工程装置下管道编号不能重复!");
}
// 同一工程装置下管道编号不能重复校验
// if (items.size() != items.stream().map(TechParamsPipelineChangeFieldDto::getPipelineNumber).distinct().count()) {
// throw new BadRequest("同一工程装置下管道编号不能重复!");
// }
List<PipelineChangeItemDto> newPipelines = new ArrayList<>();
List<PipelineChangeItemDto> updatePipelines = new ArrayList<>();
List<PipelineChangeItemDto> deletePipelines = new ArrayList<>();
......
......@@ -58,7 +58,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
......@@ -92,7 +91,6 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterI
public class DataDockServiceImpl {
private final SnowflakeIdUtil sequence;
private final ESEquipmentCategory esEquipmentCategory;
private final SuperviseInfoMapper superviseInfoMapper;
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
private final IIdxBizJgUseInfoService idxBizJgUseInfoService;
private final IIdxBizJgProjectContraptionService idxBizJgProjectContraptionService;
......@@ -113,7 +111,6 @@ public class DataDockServiceImpl {
private final IdxBizJgProjectContraptionServiceImplService idxBizJgProjectContraptionServiceImpl;
private final IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
private final JgInstallationNoticeServiceImpl installationNoticeService;
private final TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageService;
private final RedisUtils redisUtils;
private final JgUseRegistrationServiceImpl jgUseRegistrationServiceImpl;
......@@ -133,7 +130,6 @@ public class DataDockServiceImpl {
private final JgResumeInfoServiceImpl jgResumeInfoService;
private final IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
private final Map<String, Object> resultError = new HashMap<>();
private final JgUseRegistrationMapper jgUseRegistrationMapper;
List<String> useInnerCodeList = new ArrayList<>();// 单位内部编号集合
List<String> equCodeList = new ArrayList<>();// 设备代码集合
List<String> factoryNumList = new ArrayList<>();// 出厂编码集合
......@@ -150,15 +146,19 @@ public class DataDockServiceImpl {
// 设备基本信息表单id
public static final String EQUIP_INFO_FORM_ID = "equipInfo";
// 设备技术参数表单id
public static final String EQUIP_PARAMS_FORM_ID = "equipParams";
private static final String ATTACHMENT_UPLOAD = "attachmentUpload";
// 模版上传集合
public static final String EQU_LISTS = "equLists";
@Autowired
private EventPublisher eventPublisher;
@Autowired
private JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
private final EventPublisher eventPublisher;
private final JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
private final IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private final IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
private final IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
private final IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
private final IdxBizJgConstructionInfoMapper idxBizJgConstructionInfoMapper;
private final IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
private final IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper;
/**
* 西安数据对接-保存设备信息
......@@ -1023,17 +1023,17 @@ public class DataDockServiceImpl {
.stream()
.map(item -> (String) item.get("pipelineNumber"))
.collect(Collectors.toList());
if (pipelineNumberList.contains(data.getPipelineNumber())) {
rowError.append(String.format("系统中工程装置(%s)下已经存在管道编号(%s);", data.getProjectContraption(), data.getPipelineNumber()));
}
// if (pipelineNumberList.contains(data.getPipelineNumber())) {
// rowError.append(String.format("系统中工程装置(%s)下已经存在管道编号(%s);", data.getProjectContraption(), data.getPipelineNumber()));
// }
});
List<String> list = projectContraptionMap.get(data.getProjectContraption());
if (null != list) {
// 判断该装置下是否已经存在该管道编号
if (list.contains(data.getPipelineNumber())) {
rowError.append(String.format("同一工程装置(%s)下管道编号不能重复;", data.getProjectContraption()));
}
// if (list.contains(data.getPipelineNumber())) {
// rowError.append(String.format("同一工程装置(%s)下管道编号不能重复;", data.getProjectContraption()));
// }
list.add(data.getPipelineNumber());
} else {
list = new ArrayList<>();
......@@ -1691,13 +1691,13 @@ public class DataDockServiceImpl {
//checkNotBlank(data.getMedium(), "设计-介质不能为空;", rowError);
//checkNotBlank(data.getTemperature(), "设计-温度不能为空;", rowError);
//checkNotBlank(data.getPipelineNumber(), "管道编号不能为空;", rowError);
Optional.ofNullable(data.getPipelineNumber()).ifPresent(v -> {
if (pipelineNumList.contains(v)) {
rowError.append("管道编号不能重复");
} else {
pipelineNumList.add(v);
}
});
// Optional.ofNullable(data.getPipelineNumber()).ifPresent(v -> {
// if (pipelineNumList.contains(v)) {
// rowError.append("管道编号不能重复");
// } else {
// pipelineNumList.add(v);
// }
// });
//checkNotBlank(data.getDeviceLevel(), "管道级别不能为空;", rowError);
......@@ -2063,6 +2063,7 @@ public class DataDockServiceImpl {
useInfo.setProjectContraption(paramsDto.getProjectContraption());
useInfo.setUseDate(paramsDto.getUseDate());
useInfo.setProjectContraptionId(paramsDto.getProjectContraptionSeq());
useInfo.setDataQualityScore(StringUtils.isEmpty(paramsDto.getUseOrgCode()) ? 3 : 1);
useInfoList.add(useInfo);
// 检验检测信息
......@@ -2189,17 +2190,38 @@ public class DataDockServiceImpl {
}
esEquipmentCategoryList.add(esEquipmentDto);
}
idxBizJgUseInfoService.saveBatch(useInfoList);
idxBizJgDesignInfoService.saveBatch(designInfoList);
idxBizJgConstructionInfoService.saveBatch(constructionInfoList);
idxBizJgFactoryInfoService.saveBatch(factoryInfoList);
idxBizJgRegisterInfoServiceImpl.saveBatch(registerInfoList);
idxBizJgOtherInfoService.saveBatch(otherInfoList);
idxBizJgSupervisionInfoService.saveBatch(supervisionInfoList);
iIdxBizJgTechParamsPipelineService.saveBatch(paramsPipelineList);
idxBizJgInspectionDetectionInfoService.saveBatch(inspectionDetectionInfoList);
esEquipmentCategory.saveAll(esEquipmentCategoryList);
CompletableFuture<Void> useInfoFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息"));
CompletableFuture<Void> designInfoFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息"));
CompletableFuture<Void> constructionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgConstructionInfoMapper, constructionInfoList, "施工信息"));
CompletableFuture<Void> factoryFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息"));
CompletableFuture<Void> registerFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "登记信息"));
CompletableFuture<Void> otherFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgOtherInfoMapper, otherInfoList, "其他信息"));
CompletableFuture<Void> supervisionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监管信息"));
CompletableFuture<Void> paramsPipelineFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgTechParamsPipelineMapper, paramsPipelineList, "管道参数信息"));
CompletableFuture<Void> inspectionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息"));
CompletableFuture<Void> esFuture = CompletableFuture.runAsync(() -> {
if (!esEquipmentCategoryList.isEmpty()) {
esEquipmentCategory.saveAll(esEquipmentCategoryList);
log.info("ES批量保存完成,数量:{}", esEquipmentCategoryList.size());
}
});
CompletableFuture.allOf(
useInfoFuture, designInfoFuture, constructionFuture, factoryFuture,
registerFuture, otherFuture, supervisionFuture, paramsPipelineFuture,
inspectionFuture, esFuture
).join();
log.info("所有批量操作完成");
return recordList;
}
......@@ -2438,6 +2460,7 @@ public class DataDockServiceImpl {
.supervisoryCode(idxBizJgRegisterInfoServiceImpl.getSupervisoryCode(paramsDto.getVehicleApanage(), paramsDto.getEquCategoryCode())).isIntoManagement(Boolean.TRUE).dataSource(paramsDto.getDataSource()).equCode(paramsDto.getEquCode()).isFirstMerge(Boolean.FALSE).build();
contraption.setSequenceNbr(seq);
contraption.setCreateDate(new Date());
contraption.setDataQualityScore(StringUtils.isEmpty(paramsDto.getUseOrgCode()) ? "3" : "1");
paramsDto.setProjectContraptionSeq(String.valueOf(seq));
idxBizJgProjectContraptionService.save(contraption);
return contraption;
......
......@@ -53,9 +53,9 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
......@@ -63,6 +63,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -75,6 +76,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
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;
......@@ -1536,7 +1538,6 @@ public class DataHandlerServiceImpl {
return license;
}).collect(Collectors.toList());
}
public Integer initEquipStatistData2EsBatch() {
log.info("综合统计设备信息入库开始");
StopWatch watch = new StopWatch();
......
......@@ -1524,11 +1524,12 @@ public class EquipClaimServiceImpl {
CompanyBo company = getSelectedOrgInfo().getCompany();
// 管道校验
//同一工程装置下管道编号不能重复校验
List<Map<String, Object>> pipelineList = (List<Map<String, Object>>) equipInfo.get(PIPELINE_LIST);
if (CollectionUtils.isEmpty(pipelineList) || pipelineList.size() != pipelineList.stream()
.map(v -> (String) v.get("pipelineNumber")).distinct().count()) {
throw new BadRequest(CollectionUtils.isEmpty(pipelineList) ? "请填写管道信息!" : "同一工程装置下管道编号不能重复!");
}
// if (CollectionUtils.isEmpty(pipelineList) || pipelineList.size() != pipelineList.stream()
// .map(v -> (String) v.get("pipelineNumber")).distinct().count()) {
// throw new BadRequest(CollectionUtils.isEmpty(pipelineList) ? "请填写管道信息!" : "同一工程装置下管道编号不能重复!");
// }
// 需要融合的判断融合后的管道编号是否重复
String proConNo = equipInfo.getString(PROJECT_CONTRAPTION_NO);
IdxBizJgProjectContraption oldProCon = idxBizJgProjectContraptionService.getBaseMapper().selectOne(new LambdaQueryWrapper<IdxBizJgProjectContraption>()
......
......@@ -29,6 +29,7 @@ import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EquipmentCategoryService;
import com.yeejoin.amos.boot.module.jg.api.common.DataDockTemplateVersionUtils;
......@@ -114,6 +115,8 @@ import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum.SPECIAL_CYLINDER;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XIAN_YANG;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XI_XIAN;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl.IDX_BIZ_EQUIPMENT_INFO;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl.IDX_BIZ_VIEW_JG_ALL;
/**
......@@ -210,7 +213,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
@Autowired
private IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
@Autowired
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
@Autowired
private IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
@Autowired
private IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
@Autowired
private IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
@Autowired
private IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper;
@Autowired
IdxBizJgOtherInfoMapper otherInfoMapper;
@Autowired
......@@ -535,11 +550,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 单位类型
Map<String, Object> companyInfoMap = jgInstallationNoticeService.getCompanyType();
String companyTypeStr = companyInfoMap.get("companyType").toString();
if (CollectionUtils.isEmpty(pipelineList) || pipelineList.size() != pipelineList.stream()
.map(v -> (String) v.get("pipelineNumber")).distinct().count()) {
throw new BadRequest(CollectionUtils.isEmpty(pipelineList) ? "请填写管道信息!" : "同一工程装置下管道编号不能重复!");
}
//去掉同一装置管道编号唯一性校验
// if (CollectionUtils.isEmpty(pipelineList) || pipelineList.size() != pipelineList.stream()
// .map(v -> (String) v.get("pipelineNumber")).distinct().count()) {
// throw new BadRequest(CollectionUtils.isEmpty(pipelineList) ? "请填写管道信息!" : "同一工程装置下管道编号不能重复!");
// }
// 工程装置信息
IdxBizJgProjectContraption projectContraption = JSON.parseObject(toJSONString(equipmentInfoForm), IdxBizJgProjectContraption.class);
......@@ -4021,44 +4036,172 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
equCodeList.clear();
factoryNumList.clear();
try {
// 判断模板版本号
String templateVersionError = DataDockTemplateVersionUtils.checkTemplateVersion(multipartFile);
if (!ValidationUtil.isEmpty(templateVersionError)) {
resultError.add(templateVersionError);
throw new BadRequest(templateVersionError);
}
EasyExcel.read(multipartFile.getInputStream(), EquipInfoCylinderExcelDto.class, new AnalysisEventListener<EquipInfoCylinderExcelDto>() {
// 每读取一行就调用该方法
EasyExcel.read(multipartFile.getInputStream(), EquipInfoCylinderExcelDto.class,
new AnalysisEventListener<EquipInfoCylinderExcelDto>() {
@Override
public void invoke(EquipInfoCylinderExcelDto data, AnalysisContext context) {
EquipInfoCylinderExcelDto fireExperts = new EquipInfoCylinderExcelDto();
BeanUtils.copyProperties(data, fireExperts);
resultError.add(checkExcelData(data, context).toString());
aircraftList.add(fireExperts);
EquipInfoCylinderExcelDto copy = new EquipInfoCylinderExcelDto();
BeanUtils.copyProperties(data, copy);
aircraftList.add(copy);
useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode());
factoryNumList.add("0".equals(data.getWhetherVehicleCylinder()) ? data.getProduceUnitCreditCode() + "_" +data.getFactoryNum() : null);
String checkMsg = checkExcelData(data, context).toString();
if (!checkMsg.isEmpty()) {
resultError.add(checkMsg);
}
}
// 全部读取完成就调用该方法
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtils.isEmpty(aircraftList)) {
log.info("你上传了一个空数据的Excel文档!");
resultError.add("你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
String msg = "你上传了一个空数据的Excel文档!";
resultError.add(msg);
throw new BadRequest(msg);
}
}
}).headRowNumber(4).sheet().doRead();
if (resultError.stream().anyMatch(input -> !input.isEmpty())) {
if (resultError.stream().anyMatch(s -> !s.isEmpty())) {
throw new BadRequest("上传失败!");
}
List<String> warnings = checkExcelDuplicates(aircraftList);
Set<String> nonVehicleKeys = new HashSet<>();
Set<String> vehicleFactoryNums = new HashSet<>();
Set<String> equCodeKeys = new HashSet<>();
for (EquipInfoCylinderExcelDto data : aircraftList) {
if ("1".equals(data.getEquCodeType()) && StringUtils.isNotEmpty(data.getEquCode())) {
equCodeKeys.add(data.getEquCode());
}
if ("0".equals(data.getWhetherVehicleCylinder())) { // 非车用
if (StringUtils.isNotEmpty(data.getProduceUnitCreditCode()) &&
StringUtils.isNotEmpty(data.getFactoryNum())) {
nonVehicleKeys.add(data.getProduceUnitCreditCode() + "_" + data.getFactoryNum());
}
} else { // 车用
if (StringUtils.isNotEmpty(data.getFactoryNum())) {
vehicleFactoryNums.add(data.getFactoryNum());
}
}
}
Map<String, String> nonVehicleMap = batchQueryEs(nonVehicleKeys, true);//普通气瓶
Map<String, String> vehicleMap = batchQueryEs(vehicleFactoryNums, false);//车用气瓶
List<String> equCodes = new ArrayList<>();
for (EquipInfoCylinderExcelDto data : aircraftList) {
String exist;
if ("0".equals(data.getWhetherVehicleCylinder())) {
exist = nonVehicleMap.get(data.getFactoryNum());
} else {
exist = vehicleMap.get(data.getFactoryNum());
}
if (exist != null) {
warnings.add(String.format("制造单位[%s]生产的出厂编号为[%s]的气瓶,已被[%s]录入系统,请核实!", data.getProduceUnitName(), data.getFactoryNum(), exist));
}
//校验设备代码重复
equCodes = this.checkEquCodeExist(equCodeKeys);
}
if (!equCodes.isEmpty()) {
resultError.add("导入气瓶模板中,以下设备代码系统中已存在: " + String.join(",", equCodes));
}
if (!warnings.isEmpty()) {
resultError.addAll(warnings);
throw new BadRequest(resultError.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("<br/>")));
}
return aircraftList;
} catch (Exception e) {
throw new Exception(resultError.stream()
.filter(s -> !s.isEmpty())
.collect(Collectors.joining("<br/>")));
throw new Exception(resultError.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("<br/>")));
}
}
private List<String> checkEquCodeExist(Set<String> equCodeKeys) throws IOException {
List<String> equCodes;
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
.must(QueryBuilders.termsQuery("EQU_CODE", equCodeKeys))
.must(QueryBuilders.termQuery("STATUS", "已认领"));
SearchRequest request = new SearchRequest(IDX_BIZ_VIEW_JG_ALL);
request.source(new SearchSourceBuilder()
.query(boolQuery)
.fetchSource(new String[]{"EQU_CODE"}, null)
.size(10000)
);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
equCodes = Arrays.stream(response.getHits().getHits())
.map(hit -> (String) hit.getSourceAsMap().get("EQU_CODE"))
.filter(Objects::nonNull)
.collect(Collectors.toList());
return equCodes;
}
/** Excel 内部重复校验 */
private List<String> checkExcelDuplicates(List<EquipInfoCylinderExcelDto> list) {
List<String> warnings = new ArrayList<>();
Set<String> nonVehicleSet = new HashSet<>();
Set<String> vehicleSet = new HashSet<>();
for (EquipInfoCylinderExcelDto data : list) {
if ("0".equals(data.getWhetherVehicleCylinder())) {
String key = data.getProduceUnitCreditCode() + "_" + data.getFactoryNum();
if (!nonVehicleSet.add(key)) {
warnings.add(String.format(
"您上传的Excel内部发现重复:制造单位[%s]生产的出厂编号为[%s]的气瓶重复!",
data.getProduceUnitName(), data.getFactoryNum()));
}
} else {
String key = data.getFactoryNum();
if (!vehicleSet.add(key)) {
warnings.add(String.format(
"您上传的Excel内部发现重复:车用气瓶出厂编号[%s]重复!",
data.getFactoryNum()));
}
}
}
return warnings;
}
/** 批量查询 ES */
private Map<String, String> batchQueryEs(Set<String> keys, boolean nonVehicle) throws IOException {
Map<String, String> resultMap = new HashMap<>();
if (CollectionUtils.isEmpty(keys)) return resultMap;
SearchRequest request = new SearchRequest(IDX_BIZ_EQUIPMENT_INFO);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().size(10000)
.fetchSource(new String[]{"FACTORY_NUM", "PRODUCE_UNIT_NAME"}, null);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("EQU_LIST_CODE", "2000"))
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.termQuery("STATUS", "已认领"));
if (nonVehicle) {
List<String> creditCodes = keys.stream().map(k -> k.split("_")[0]).collect(Collectors.toList());
List<String> factoryNums = keys.stream().map(k -> k.split("_")[1]).collect(Collectors.toList());
boolQuery.must(QueryBuilders.termsQuery("FACTORY_NUM", factoryNums))
.must(QueryBuilders.termsQuery("produceUnitCreditCode", creditCodes));
} else {
boolQuery.must(QueryBuilders.termsQuery("FACTORY_NUM", keys))
.must(QueryBuilders.termQuery("EQU_DEFINE_CODE", "23T0"))
.must(QueryBuilders.termQuery("WHETHER_VEHICLE_CYLINDER", "1"));
}
sourceBuilder.query(boolQuery);
request.source(sourceBuilder);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
Map<String, Object> src = hit.getSourceAsMap();
String factoryNum = Objects.toString(src.get("FACTORY_NUM"), "");
String produceUnitName = Objects.toString(src.get("PRODUCE_UNIT_NAME"), "");
resultMap.put(factoryNum, produceUnitName);
}
return resultMap;
}
private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
......@@ -4151,6 +4294,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.orElse(String.valueOf(EquimentEnum.ZAIYONG.getCode())))
: String.valueOf(EquimentEnum.WEIDENGJI.getCode());
useInfo.setEquState(equState);
useInfo.setDataQualityScore(StringUtils.isEmpty(equipInfoDto.getUseOrgCode()) ? 3 : 1);
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
......@@ -4419,21 +4563,31 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.collect(Collectors.toList())
);
}
Optional.of(supervisionInfoList).filter(list -> !list.isEmpty()).ifPresent(iIdxBizJgSupervisionInfoService::saveBatch);
Optional.of(useInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgUseInfoService::saveBatch);
Optional.of(designInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgDesignInfoService::saveBatch);
Optional.of(registerInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgRegisterInfoService::saveBatch);
Optional.of(factoryInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgFactoryInfoService::saveBatch);
Optional.of(otherInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgOtherInfoService::saveBatch);
Optional.of(paramsVesselList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgTechParamsVesselService::saveBatch);
Optional.of(inspectionDetectionInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgInspectionDetectionInfoService::saveBatch);
Optional.of(esEquipmentCategoryList).filter(list -> !list.isEmpty()).ifPresent(esEquipmentCategory::saveAll);
batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监督信息");
batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息");
batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息");
batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "注册信息");
batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息");
batchInsert(otherInfoMapper, otherInfoList, "其他信息");
batchInsert(idxBizJgTechParamsVesselMapper, paramsVesselList, "容器参数信息");
batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息");
if (!esEquipmentCategoryList.isEmpty()) {
esEquipmentCategory.saveAll(esEquipmentCategoryList);
}
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
}
/** 通用批量插入方法 */
public <T> void batchInsert(CustomBaseMapper<T> mapper, List<T> list, String name) {
if (list != null && !list.isEmpty()) {
mapper.insertBatchSomeColumn(list, 1000);
log.info("{} 批量插入完成,数量:{}", name, list.size());
} else {
log.info("{} 列表为空,无需插入", name);
}
}
public String buildTaskModel(JgUseRegistration jgUseRegistration, String equListCode) {
TaskModelDto modelDto = new TaskModelDto();
modelDto.setNextExecuteUser(jgUseRegistration.getNextExecuteUserIds());
......@@ -4725,12 +4879,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (!equCode.matches("[a-zA-Z0-9]+")) {
result.append("设备代码不能包含特殊字符;");
} else {
Stream.of(equCode.length() <= 17 ? "设备代码不能小于17位;" : "",
equCode.length() >= 20 ? "设备代码不能大于20位;" : "",
equCodeList.contains(equCode) ? "设备代码不能重复;" : ""
String code = equCode.trim();
Stream.of(code.length() < 17 ? "设备代码不能小于17位;" : "",
code.length() > 20 ? "设备代码不能大于20位;" : ""
).filter(msg -> !msg.isEmpty())
.forEach(result::append);
this.checkEquCodeUniqueness(equCode, result);
if (equCodeList.contains(code)) {
result.append("设备代码不能重复").append(code);
}
equCodeList.add(data.getEquCode());
//this.checkEquCodeUniqueness(equCode, result);
}
});
} else {
......@@ -4744,19 +4902,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//checkNotBlank(data.getProduceUnitName(), "制造单位名称不能为空;", result);
// checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空;", result);
//checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空;", result);
if ("0".equals(data.getWhetherVehicleCylinder())) {
// checkNotBlank(data.getCylinderCategory(), "气瓶分类不能为空;", result);
if (!StringUtils.isEmpty(data.getFactoryNum()) && !StringUtils.isEmpty(data.getProduceUnitCreditCode())){
checkFactoryNumUnique(data.getFactoryNum(), data.getProduceUnitCreditCode(), data.getProduceUnitName(), result);
if (factoryNumList.contains(data.getProduceUnitCreditCode() + "_" +data.getFactoryNum())){
result.append("同一制造单位下,出厂编码不能重复!;");
}
}
} else {
if (!StringUtils.isEmpty(data.getFactoryNum())){
checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum(), result);
}
}
// if ("0".equals(data.getWhetherVehicleCylinder())) {
//// checkNotBlank(data.getCylinderCategory(), "气瓶分类不能为空;", result);
// if (!StringUtils.isEmpty(data.getFactoryNum()) && !StringUtils.isEmpty(data.getProduceUnitCreditCode())){
// checkFactoryNumUnique(data.getFactoryNum(), data.getProduceUnitCreditCode(), data.getProduceUnitName(), result);
// if (factoryNumList.contains(data.getProduceUnitCreditCode() + "_" +data.getFactoryNum())){
// result.append("同一制造单位下,出厂编码不能重复!;");
// }
// }
// } else {
// if (!StringUtils.isEmpty(data.getFactoryNum())){
// checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum(), result);
// }
// }
// checkNotBlank(data.getProduceDate(), "制造日期不能为空;", result);
Optional.ofNullable(data.getProduceDate()).ifPresent(v -> checkDateFormatCorrect(v, "制造日期格式不正确;", result));
//checkNotBlank(data.getInspectOrgName(), "检测机构名称不能为空;", result);
......
......@@ -251,7 +251,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
String equSeq = !EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode()) ? SEQUENCE_NBR : RECORD;
List<Map<String, Object>> deviceList = noticeDto.getDeviceList();
// 管道校验管道编号不重复
this.verifyThatThePipeNumberIsUnique(notice.getEquListCode(), deviceList);
//去掉同一工程装置下管道编号不能重复校验
//this.verifyThatThePipeNumberIsUnique(notice.getEquListCode(), deviceList);
List<String> records = Optional.ofNullable(deviceList)
.orElse(Collections.emptyList())
.stream()
......@@ -504,7 +505,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
String equSeq = !EquipmentClassifityEnum.YLGD.getCode().equals(equListCode) ? SEQUENCE_NBR : RECORD;
// 管道校验管道编号不重复
this.verifyThatThePipeNumberIsUnique(equListCode, deviceList);
//去掉同一工程装置下管道编号不能重复校验
//this.verifyThatThePipeNumberIsUnique(equListCode, deviceList);
// 提交时对设备状态进行校验(处理并发问题,一个未被使用的设备同时被多个使用这打开,同时提交发起申请) todo 回滚异常未写
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
if (CollectionUtils.isEmpty(deviceList)) {
......
......@@ -968,6 +968,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
map.put("safetyManagerId", data[0]);
map.put("safetyManagerName", data[1]);
});
// 使用单位Code
Optional.ofNullable(map.getString("useUnitCreditCode"))
.filter(unitCode -> unitCode.contains("_"))
.map(unitCode -> unitCode.split("_"))
.ifPresent(unitCode -> {
map.put("useUnitCreditCode", unitCode[0]);
map.put("useUnitName", unitCode[1]);
});
// 其他附件
if (!ObjectUtils.isEmpty(map.get("otherAccessories"))) {
......@@ -1322,6 +1330,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jgProjectContraption.setUseRegistrationCode(jgUseRegistration.getUseRegistrationCode());
jgProjectContraption.setUscUnitCreditCode("");
jgProjectContraption.setUscUnitName("");
jgProjectContraption.setRecUserId(jgUseRegistration.getCreateUserId());
jgProjectContraptionService.updateById(jgProjectContraption);
}
// 取第一条设备的注册消息--用来获取这一批设备的设备种类/类别/品种
......@@ -1586,6 +1595,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JgUseRegistrationManage jgUseRegistrationManage = new JgUseRegistrationManage();
jgUseRegistrationManage.setAuditPassDate(jgUseRegistration.getAuditPassDate());
jgUseRegistrationManage.setSequenceNbr(useRegistrationManageSeq);
jgUseRegistrationManage.setRecUserId(jgUseRegistration.getCreateUserId());
this.setSuperviseOrgInfo(jgUseRegistrationManage, jgUseRegistration);
jgUseRegistrationManageMapper.updateById(jgUseRegistrationManage);
return;
......
......@@ -311,6 +311,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
// 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType);
if ("custom".equals(filterType)) {
JSONArray leftGroup = filterParams.getJSONArray("group1");
JSONArray rightGroup = filterParams.getJSONArray("group2");
licensesStatusStr = getFilterPermitStatusOrLicensesStatus(leftGroup, rightGroup, StatisticalAnalysisEnum.person.getCode());
} else {
// 资质判断
if (filterParams.containsKey("expiryDate")) {
Object permitStatus = filterParams.get("expiryDate");
......@@ -321,13 +326,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
}
if (filterParams.containsKey("certNo") && filterParams.getJSONArray("certNo").size() == 1 && "0".equals(filterParams.getJSONArray("certNo").get(0).toString())) {
licensesStatusStr = noLicenseReq;
}
}
if ("custom".equals(filterType)) {
JSONArray leftGroup = filterParams.getJSONArray("group1");
JSONArray rightGroup = filterParams.getJSONArray("group2");
licensesStatusStr = getFilterPermitStatusOrLicensesStatus(leftGroup, rightGroup, StatisticalAnalysisEnum.person.getCode());
}
// 组装人员排序条件
this.getPersonBoolQuerySort(filter, builder);
......@@ -808,6 +812,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private String getFilterPermitStatusOrLicensesStatus(JSONArray leftGroup, JSONArray rightGroup, String code) {
String filed = code.equals(StatisticalAnalysisEnum.company.getCode()) ? "permitStatus" : "expiryDate";
List<Object> LeftNoLicenseList = leftGroup.stream().filter(e->"certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn") ).collect(Collectors.toList());
List<Object> rightNoLicenseList = rightGroup.stream().filter(e->"certNo".equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).getString("value").equals("0") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn") ).collect(Collectors.toList());
Boolean noLicense = false;
if (LeftNoLicenseList.size() > 0 || rightNoLicenseList.size() > 0) {
noLicense = true;
}
List<Object> leftPermitList = leftGroup.stream().filter(e -> filed.equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn")).collect(Collectors.toList());
List<Object> rightPermitList = rightGroup.stream().filter(e -> filed.equals(((JSONObject) e).getString("field")) && ((JSONObject) e).containsKey("value") && ((JSONObject) e).containsKey("itemCondition") && !((JSONObject) e).getString("itemCondition").equals("notIn")).collect(Collectors.toList());
int count = 0;
......@@ -822,9 +832,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
isRight = true;
}
String statusStr = "";
if (count == 1 && isLeft) {
if (count == 1 && isLeft && !noLicense) {
statusStr = ((JSONObject) leftPermitList.get(0)).getString("value");
} else if (count == 1 && isRight) {
} else if (count == 1 && isRight && !noLicense) {
statusStr = ((JSONObject) rightPermitList.get(0)).getString("value");
}
return statusStr;
......@@ -1577,6 +1587,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
for (int i = 0; i < group.size(); i++) {
JSONObject itemObj = group.getJSONObject(i);
String andOr = i == 0 ? null : itemObj.getString("andOr");
if (group.size() > 1 && i == 0) {
JSONObject nextItemObj = group.getJSONObject(i + 1);
andOr = nextItemObj.getString("andOr").equals(or) ? or : and;
}
String field = itemObj.getString("field");
String itemCondition = itemObj.getString("itemCondition");
Object value = itemObj.get("value");
......@@ -1754,17 +1768,23 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lte(LocalDate.now().plusDays(30).format(formatter)).gte(LocalDate.now().format(formatter))),
ScoreMode.None
);
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
existsQuery(nestedField),
ScoreMode.None
);
builder.add(nestedQuery, and);
if (value.equals(overdue)) {
if (itemCondition.equals("eq") || itemCondition.equals("in")) {
builder.add(QueryBuilders.boolQuery().must(overdueNestedQuery), isOr);
} else {
EnhancedDynamicQueryBuilder builders = new EnhancedDynamicQueryBuilder();
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
NestedQueryBuilder otherQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).gte(LocalDate.now().format(formatter))),
ScoreMode.None
);
builders.add(QueryBuilders.boolQuery().must(nestedQuery), or);
builders.add(QueryBuilders.boolQuery().must(otherQuery), or);
builders.add(QueryBuilders.boolQuery().must(noneQuery), or);
builders.add(QueryBuilders.boolQuery().mustNot(overdueNestedQuery), and);
builder.add(builders.build(), isOr);
......@@ -1785,12 +1805,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
builder.add(normalNestedQuery, isOr);
} else {
EnhancedDynamicQueryBuilder builders = new EnhancedDynamicQueryBuilder();
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
NestedQueryBuilder otherQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lte(LocalDate.now().plusDays(30).format(formatter))),
ScoreMode.None
);
builders.add(QueryBuilders.boolQuery().must(nestedQuery), or);
builders.add(QueryBuilders.boolQuery().must(otherQuery), or);
builders.add(QueryBuilders.boolQuery().must(noneQuery), or);
builders.add(QueryBuilders.boolQuery().mustNot(normalNestedQuery), and);
builder.add(builders.build(), isOr);
......
......@@ -14,7 +14,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
......@@ -28,13 +27,14 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -51,6 +51,8 @@ public class EquipmentStaticsServiceImpl {
private static final String EQUSTATE = "EQU_STATE";
private static final String SUPERVISORYCODE = "SUPERVISORY_CODE";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Resource
private SafetyProblemTracingMapper safetyProblemTracingMapper;
......@@ -297,15 +299,21 @@ public class EquipmentStaticsServiceImpl {
public Page<Map<String, Object>> normalPage(Integer current, Integer size, DPFilterParamForDetailDto dpFilterParamForDetailDto) {
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamForDetailDto.getCityCode());
if(dpFilterParamForDetailDto.getOrgBranchCode() != null){
if(dpFilterParamForDetailDto.getOrgBranchCode().contains("_")){
String code = dpFilterParamForDetailDto.getOrgBranchCode().split("_")[0];
orgCode = stCommonService.getAndSetOrgCode(code);
}
}
if(StringUtils.isEmpty(orgCode)){
return new Page<>(current,size);
}
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
request.indices("idx_biz_equipment_info");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
boolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode ));
if (StringUtils.isNotEmpty(dpFilterParamForDetailDto.getTreeValue())) {
if ("2300".equals(dpFilterParamForDetailDto.getTreeValue())){
......@@ -315,30 +323,22 @@ public class EquipmentStaticsServiceImpl {
}
}
// 且8大类,目的去掉脏数据
boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", StCommonServiceImpl.getEquipmentCategory().stream().map(EquipmentCategoryDto::getCode).collect(Collectors.toList())));
// boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", StCommonServiceImpl.getEquipmentCategory().stream().map(EquipmentCategoryDto::getCode).collect(Collectors.toList())));
String[] status = {"草稿","已拒领","待认领"};
boolMust.mustNot(QueryBuilders.termsQuery("STATUS",Arrays.asList(status)));
//检验状态0临期1超期
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getInspectionStatus())){
if(StringUtils.equals("0",dpFilterParamForDetailDto.getInspectionStatus())){
// 且下次检验日期大于等于当天 且查询 下次检验日期 <= 当前天+30天 即为临期
long currentDayTime = DateUtil.parse(DateUtil.today(), "yyy-MM-dd").getTime();
long currentDayAfter30DayTime = DateUtil.offsetDay(DateUtil.parse(DateUtil.today(), "yyy-MM-dd"), 30).getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(currentDayTime).lte(currentDayAfter30DayTime));
}else{
// 查询下次检验日期小于当前天的设备,即为超期检验超期设备
List<String> typeList = new ArrayList<>();
typeList.add("维保超期");
typeList.add("检验超期");
List<String> sourceIds = safetyProblemTracingMapper.getSourceId(orgCode,typeList);
boolMust.must(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword",sourceIds));
if (StringUtils.isNotEmpty(dpFilterParamForDetailDto.getInspectionStatus())) {
if (StringUtils.equals("0", dpFilterParamForDetailDto.getInspectionStatus())) {
boolMust.filter(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(LocalDate.now().format(formatter)).lte(LocalDate.now().plusDays(30).format(formatter)));
} else {
boolMust.filter(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lt(LocalDate.now().format(formatter)));
}
}
/**
* 使用单位
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getUseUnitName())){
boolMust.must(QueryBuilders.matchPhraseQuery("USE_UNIT_NAME", "*" + dpFilterParamForDetailDto.getUseUnitName() + "*"));
boolMust.must(QueryBuilders.wildcardQuery("USE_UNIT_NAME", "*" + dpFilterParamForDetailDto.getUseUnitName() + "*"));
}
/**
* 使用登记编号
......@@ -350,50 +350,51 @@ public class EquipmentStaticsServiceImpl {
* 96333
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getCode96333())){
boolMust.must(QueryBuilders.matchPhraseQuery("CODE96333", "*" + dpFilterParamForDetailDto.getCode96333() + "*"));
boolMust.must(QueryBuilders.wildcardQuery("CODE96333", "*" + dpFilterParamForDetailDto.getCode96333() + "*"));
}
/**
* 监管码
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getSupervisoryCode())){
boolMust.must(QueryBuilders.matchPhraseQuery("SUPERVISORY_CODE", "*" + dpFilterParamForDetailDto.getSupervisoryCode() + "*"));
boolMust.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*" + dpFilterParamForDetailDto.getSupervisoryCode() + "*"));
}
/**
* 所属地区
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getUsePlace())){
boolMust.must(QueryBuilders.matchPhraseQuery("USE_PLACE", "*" + dpFilterParamForDetailDto.getUsePlace() + "*"));
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE", "*" + dpFilterParamForDetailDto.getUsePlace() + "*"));
}
/**
* 设备状态
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getEquState())){
boolMust.must(QueryBuilders.matchPhraseQuery("EQU_STATE", dpFilterParamForDetailDto.getEquState()));
boolMust.must(QueryBuilders.matchPhraseQuery("EQU_STATE", EquimentEnum.getCode.get(dpFilterParamForDetailDto.getEquState())));
}
/**
* 信息化
*/
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getInformationSituation())){
boolMust.must(QueryBuilders.matchPhraseQuery("INFORMATION_SITUATION","*" + dpFilterParamForDetailDto.getInformationSituation() + "*"));
boolMust.must(QueryBuilders.matchQuery("INFORMATION_SITUATION", dpFilterParamForDetailDto.getInformationSituation()));
}
/**
* 设备类别
*/
if(StrUtil.isNotEmpty(dpFilterParamForDetailDto.getEquCategory())){
boolMust.must(QueryBuilders.matchPhraseQuery("EQU_CATEGORY", "*" + dpFilterParamForDetailDto.getEquCategory() + "*"));
boolMust.must(QueryBuilders.wildcardQuery("EQU_CATEGORY", "*" + dpFilterParamForDetailDto.getEquCategory() + "*"));
}
//监管码状态0已赋码1未赋码
if (StringUtils.isNotEmpty(dpFilterParamForDetailDto.getSupervisionCodeStatus())){
if(StringUtils.equals("0",dpFilterParamForDetailDto.getSupervisionCodeStatus())){
if (StringUtils.isNotEmpty(dpFilterParamForDetailDto.getSupervisionCodeStatus())) {
if (StringUtils.equals("0", dpFilterParamForDetailDto.getSupervisionCodeStatus())) {
boolMust.must(QueryBuilders.existsQuery("SUPERVISORY_CODE"));
boolMust.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE","null"));
}else{
boolMust.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE", "null"));
} else {
boolMust.mustNot(QueryBuilders.existsQuery("SUPERVISORY_CODE"));
}
}
if(StringUtils.isNotEmpty(dpFilterParamForDetailDto.getNextInspectionDate())){
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(DateUtil.parse(dpFilterParamForDetailDto.getNextInspectionDate()).getTime()));
String[] timeArray = dpFilterParamForDetailDto.getNextInspectionDate().split(",");
boolMust.filter(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(timeArray[0]).lte(timeArray[1]));
}
searchSourceBuilder.query(boolMust);
......
......@@ -27,5 +27,5 @@ public interface RiskReportMapper extends BaseMapper<RiskReport> {
Map<String, String> getCompanyBySeq(@Param("companySeq") String companySeq);
@Select("select all_risk_disposal_unit_org_code from tzs_risk_report where sequence_nbr = #{sequenceNbr}")
String getRiskDisposalUnitOrgCode(Long sequenceNbr);
String getAllRiskDisposalUnitOrgCode(Long sequenceNbr);
}
......@@ -218,7 +218,7 @@ public class RiskReportServiceImpl extends BaseService<RiskReport, RiskReport, R
private String buildAllRiskDisposalUnitOrgCode(String defaultOrgCode, Long sequenceNbr) {
if (!ObjectUtils.isEmpty(sequenceNbr)) {
String allRiskDisposalUnitOrgCode = riskReportMapper.getRiskDisposalUnitOrgCode(sequenceNbr);
String allRiskDisposalUnitOrgCode = riskReportMapper.getAllRiskDisposalUnitOrgCode(sequenceNbr);
if (!ObjectUtils.isEmpty(allRiskDisposalUnitOrgCode)) {
return String.join(",", Stream.concat(
Arrays.stream(allRiskDisposalUnitOrgCode.split(",")),
......
......@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.IBaseChangeData;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.JdbcType;
import java.util.Date;
......
......@@ -14,38 +14,41 @@ public enum EquipmentCategoryEnum {
* *行政区划分及对应初始监管码
*/
XZQHDT("行政区划电梯", "XZQHDT", "行政区划电梯"),
XZQH("行政区划", "XZQH", "行政区划"),
BLW("补零位", "0", "补零位"),
JGM("监管码初始码", "0000001", "监管码初始码"),
XXCSM("西咸96333初始码", "85000", "31"),
BJCSM("宝鸡96333初始码", "13000", "32"),
XYCSM("咸阳96333初始码", "75000", "33"),
TCCSM("铜川96333初始码", "05000", "34"),
WNCSM("渭南96333初始码", "13000", "35"),
YACSM("延安96333初始码", "11000", "36"),
YUCSM("榆林96333初始码", "10000", "37"),
HZCSM("汉中96333初始码", "09000", "38"),
AKCSM("安康96333初始码", "11000", "39"),
SLCSM("商洛96333初始码", "06000", "40"),
YLCSM("杨凌96333初始码", "70000", "41"),
HCCSM("韩城96333初始码", "08000", "42"),
SMCSM("神木96333初始码", "06000", "43"),
FGCSM("府谷96333初始码", "02000", "44"),
YJL("已拒领", "6037", "已拒领"),
YRL("已认领", "6035", "已认领"),
DRL("待认领", "6036", "待认领"),
CSZT("初始状态", "0", "初始状态"),
YSY("已使用", "1", "已使用"),
WSY("未使用", "2", "未使用"),
BF("报废", "6", "报废");
XZQHDT("行政区划电梯", "XZQHDT", "行政区划电梯", null),
XZQH("行政区划", "XZQH", "行政区划", null),
BLW("补零位", "0", "补零位", null),
JGM("监管码初始码", "0000001", "监管码初始码", null),
XXCSM("西咸96333初始码", "85000", "31", "610100"),
BJCSM("宝鸡96333初始码", "13000", "32", "610300"),
XYCSM("咸阳96333初始码", "75000", "33", "610400"),
TCCSM("铜川96333初始码", "05000", "34", "610200"),
WNCSM("渭南96333初始码", "13000", "35", "610500"),
YACSM("延安96333初始码", "11000", "36", "610600"),
YUCSM("榆林96333初始码", "10000", "37", "610800"),
HZCSM("汉中96333初始码", "09000", "38", "610700"),
AKCSM("安康96333初始码", "11000", "39", "610900"),
SLCSM("商洛96333初始码", "06000", "40", "611000"),
YLCSM("杨陵96333初始码", "70000", "41", "610403"),
HCCSM("韩城96333初始码", "08000", "42", "610581"),
SMCSM("神木96333初始码", "06000", "43", "610881"),
FGCSM("府谷96333初始码", "02000", "44", "610822"),
YJL("已拒领", "6037", "已拒领", null),
YRL("已认领", "6035", "已认领", null),
DRL("待认领", "6036", "待认领", null),
CSZT("初始状态", "0", "初始状态", null),
YSY("已使用", "1", "已使用", null),
WSY("未使用", "2", "未使用", null),
BF("报废", "6", "报废", null);
private String name;
private String code;
private String value;
private String cityCode;
public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>();
public static Map<String, String> getValue = new HashMap<>();
public static Map<String, String> getCityCode = new HashMap<>();
public static final Map<String, String> getCodeValueMap = new HashMap<>();
private static final Map<String, String> valueToCodeMap = new HashMap<>();
static {
......@@ -53,7 +56,11 @@ public enum EquipmentCategoryEnum {
getName.put(e.code, e.name);
getCode.put(e.value, e.code);
getValue.put(e.value, e.code);
valueToCodeMap.put("96333_"+ e.value, e.getValue() + e.getCode());
if (e.cityCode != null) {
getCityCode.put(e.cityCode, e.code);
}
getCodeValueMap.put(e.code, e.value);
valueToCodeMap.put("96333_" + e.value, e.getValue() + e.getCode());
}
}
......@@ -61,4 +68,9 @@ public enum EquipmentCategoryEnum {
public static String getCodeByValue(String value) {
return valueToCodeMap.get(value);
}
// 根据code获取对应的value
public static String getValueByCode(String code) {
return getCodeValueMap.get(code);
}
}
......@@ -6,8 +6,9 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.entity.SupervisoryCodeInfo;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -109,5 +110,29 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
@Select("SELECT * FROM tz_equipment_category WHERE parent_id = #{parentId}")
List<EquipmentCategoryDto> getEquDefineByParentId(String parentId);
@Select("SELECT\n" +
"\tri.record,\n" +
"\tri.EQU_LIST equList,\n" +
"\tui.\"CITY\" city,\n" +
"\tui.\"COUNTY\" county,\n" +
"\tui.\"IS_NOT_XIXIAN\" isNotXixian,\n" +
"\toi.code96333,\n" +
"\toi.SUPERVISORY_CODE supervisoryCode \n" +
"FROM\n" +
"\tidx_biz_jg_register_info ri\n" +
"\tLEFT JOIN idx_biz_jg_use_info ui ON ui.record = ri.record\n" +
"\tLEFT JOIN idx_biz_jg_other_info oi ON oi.record = ri.record \n" +
"WHERE\n" +
"\tri.equ_list = '3000' \n" +
"\tAND ui.IS_INTO_MANAGEMENT = 1 \n" +
"\tAND oi.SUPERVISORY_CODE IS NOT NULL \n" +
"\tAND ( oi.code96333 IS NULL OR oi.code96333 = '' ) \n" +
"\tAND ( ui.city != '610100' OR ui.\"IS_NOT_XIXIAN\" = 1 )\n" +
"\tand oi.SUPERVISORY_CODE in ('A3100-0002769')\n")
List<Map<String, String>> selectExceptionCode96333();
@Select("select * from biz_jg_supervisory_code where supervisory_code = #{supervisoryCode} ORDER BY supervisory_code")
SupervisoryCodeInfo searchSupervisoryBySupervisoryCode(@Param("supervisoryCode") String supervisoryCode);
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgConstructionInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 施工信息表 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgConstructionInfoMapper extends BaseMapper<IdxBizJgConstructionInfo> {
public interface IdxBizJgConstructionInfoMapper extends CustomBaseMapper<IdxBizJgConstructionInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-设计信息表 Mapper 接口
......@@ -9,6 +9,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgDesignInfoMapper extends BaseMapper<IdxBizJgDesignInfo> {
public interface IdxBizJgDesignInfoMapper extends CustomBaseMapper<IdxBizJgDesignInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgFactoryInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-制造信息 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgFactoryInfoMapper extends BaseMapper<IdxBizJgFactoryInfo> {
public interface IdxBizJgFactoryInfoMapper extends CustomBaseMapper<IdxBizJgFactoryInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import org.apache.ibatis.annotations.Param;
......@@ -12,7 +12,7 @@ import java.util.List;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgInspectionDetectionInfoMapper extends BaseMapper<IdxBizJgInspectionDetectionInfo> {
public interface IdxBizJgInspectionDetectionInfoMapper extends CustomBaseMapper<IdxBizJgInspectionDetectionInfo> {
List<IdxBizJgInspectionDetectionInfo> selectLastedGroupByInspectType(@Param("record") String record);
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Select;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgOtherInfoMapper extends BaseMapper<IdxBizJgOtherInfo> {
public interface IdxBizJgOtherInfoMapper extends CustomBaseMapper<IdxBizJgOtherInfo> {
@Select("select SUPERVISORY_CODE from idx_biz_jg_other_info where record = #{equipmentCode}")
String getSupervisoryCodeByEquipmentCode(@Param("equipmentCode") String equipmentCode);
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -15,7 +14,7 @@ import java.util.Map;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgRegisterInfoMapper extends BaseMapper<IdxBizJgRegisterInfo> {
public interface IdxBizJgRegisterInfoMapper extends CustomBaseMapper<IdxBizJgRegisterInfo> {
@Select("select \"USE_ORG_CODE\" from idx_biz_jg_register_info where \"RECORD\" = #{equipCode}")
String getUseOrgCodeByEquip(@Param("equipCode") String equipCode);
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
/**
......@@ -9,6 +9,6 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgSupervisionInfoMapper extends BaseMapper<IdxBizJgSupervisionInfo> {
public interface IdxBizJgSupervisionInfoMapper extends CustomBaseMapper<IdxBizJgSupervisionInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsPipeline;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-压力管道 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgTechParamsPipelineMapper extends BaseMapper<IdxBizJgTechParamsPipeline> {
public interface IdxBizJgTechParamsPipelineMapper extends CustomBaseMapper<IdxBizJgTechParamsPipeline> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsVessel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-压力容器 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgTechParamsVesselMapper extends BaseMapper<IdxBizJgTechParamsVessel> {
public interface IdxBizJgTechParamsVesselMapper extends CustomBaseMapper<IdxBizJgTechParamsVessel> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -16,7 +15,7 @@ import java.util.Map;
* @author system_generator
* @date 2023-08-16
*/
public interface IdxBizJgUseInfoMapper extends BaseMapper<IdxBizJgUseInfo> {
public interface IdxBizJgUseInfoMapper extends CustomBaseMapper<IdxBizJgUseInfo> {
void batchUpdateUseInfo(@Param("records") List<String> records, Integer code);
List<IdxBizJgUseInfo> selectXAList();
......
package com.yeejoin.amos.boot.module.ymt.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -49,4 +50,6 @@ public interface IEquipmentCategoryService {
String selectExceedElevatorCode(String prefix);
String handleErrorElevatorCode(String supervisorCode, String elevatorCode);
JSONObject batchHandlerCode96333();
}
......@@ -680,4 +680,26 @@ public class EquipmentCategoryController extends BaseController {
@RequestParam("elevatorCode") String elevatorCode) {
return ResponseHelper.buildResponse(equipmentCategoryService.handleErrorElevatorCode(supervisorCode, elevatorCode));
}
/**
* 批量更新电梯的96333码
* 1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库
* 2,码表没有直接生成后写入
*
* @return 程序处理的数据 + 异常的需要手动处理的数据集合
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT",
value = "批量更新电梯的96333码," +
"1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库," +
"2,码表没有直接生成后写入," +
"返回值:异常的需要手动处理的数据集合",
notes = "批量更新电梯的96333码," +
"1,先于【码表 biz_jg_supervisory_code】中进行匹配," +
"有的话使用码表的写入other_info数据库,2,码表没有直接生成后写入," +
"返回值:异常的需要手动处理的数据集合")
@PutMapping(value = "/batchHandlerCode96333")
public ResponseModel<JSONObject> batchHandlerCode96333() {
return ResponseHelper.buildResponse(equipmentCategoryService.batchHandlerCode96333());
}
}
......@@ -11,7 +11,9 @@ 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.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentMessageDto;
......@@ -78,6 +80,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
......@@ -114,6 +117,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String XIAN = "610100";
// 咸阳行政区划code
private static final String XIAN_YANG = "610400";
// 杨陵行政区划code
private static final String YANG_LING = "610403";
// 韩城行政区划code
private static final String HAN_CHENG = "610581";
// 神木行政区划code
private static final String SHEN_MU = "610881";
// 府谷行政区划code
private static final String FU_GU = "610822";
// 判断行政区划查询市还是区
private static final String END_CODE = "0000";
// 判断行政区划查询街道
......@@ -189,7 +200,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired
EquipmentCategoryDataMapper equipmentCategoryDataMapper;
@Autowired
EquipmentCategoryDataServiceImpl equipmentCategoryDataService;
EsEquipmentDao esEquipmentDao;
@Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
......@@ -913,16 +924,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode.append(prefix).append(firstAvailableCode);
} else {
//// 获取补零位长度
//String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
//long num = Long.parseLong(elevatorCode1) + 1;
//int numLength = String.valueOf(num).length();
//int a = 5 - numLength;
//StringBuilder zero = new StringBuilder();
//for (int i = 0; i < a; i++) {
// String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
// long num = Long.parseLong(elevatorCode1) + 1;
// int numLength = String.valueOf(num).length();
// int a = 5 - numLength;
// StringBuilder zero = new StringBuilder();
// for (int i = 0; i < a; i++) {
// zero.append(EquipmentCategoryEnum.BLW.getCode());
//}
//zero.append(num);
//elevatorCode.append(zero);
// zero.append(num);
// elevatorCode.append(zero);
String newCode;
Integer repeatCheck;
do {
......@@ -1028,13 +1039,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
result.put(equipmentMessage.getDesInfo(), desInfo);
// 监督管理信息
Map<String, Object> supInfo = getSupInfo(map);
if(!ValidationUtil.isEmpty(supInfo.get("produceDate"))){
if (!ValidationUtil.isEmpty(supInfo.get("produceDate"))) {
LocalDate produceDate = LocalDate.parse(supInfo.get("produceDate").toString().substring(0, 10), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate localDate = LocalDate.now().minusYears(15);
if(produceDate.isBefore(localDate)){
supInfo.put("OVER_FIFTEEN_YEARS","0");
}else{
supInfo.put("OVER_FIFTEEN_YEARS","1");
if (produceDate.isBefore(localDate)) {
supInfo.put("OVER_FIFTEEN_YEARS", "0");
} else {
supInfo.put("OVER_FIFTEEN_YEARS", "1");
}
}
if ("1".equals(useInfo.get("IS_NOT_XIXIAN"))) {
......@@ -1063,7 +1074,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
result.get(EquipmentTypeEnum.DT.getSupInfo()).remove("SUPERVISORY_CODE");
}
Map<String,Object> resultMapNew = new HashMap<>();
Map<String, Object> resultMapNew = new HashMap<>();
result.forEach((key, value) -> {
resultMapNew.putAll(value);
});
......@@ -2668,4 +2679,143 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return resultMap;
}
/**
* 批量更新电梯的96333码
* 1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库
* 2,码表没有直接生成后写入
*
* @return 异常的需要手动处理的数据集合
*/
@Override
public JSONObject batchHandlerCode96333() {
log.info("开始处理96333的异常数据。。。");
// 程序无法处理的,需要手动处理的数据,需要返回
AtomicReference<Integer> handlerDataNums = new AtomicReference<>(0);
StringBuilder handlerData = new StringBuilder();
List<JSONObject> manualProcessData = new ArrayList<>();
List<Map<String, String>> exceptionData = equipmentCategoryMapper.selectExceptionCode96333();
exceptionData.forEach(data -> {
JSONObject jsonObj = JSONObject.parseObject(toJSONString(data));
String city = jsonObj.getString("city");
String county = jsonObj.getString("county");
String isNotXixian = jsonObj.getString("isNotXixian");
if (StringUtils.isEmpty(city) || "null".equals(city)) {
manualProcessData.add(jsonObj);
return;
}
// 监管码
String supervisoryCode = jsonObj.getString("supervisoryCode");
// record
String record = jsonObj.getString("record");
String code96333 = "";
String createStatus = "";
// 1. 先查码表,有则使用码表中的code96333更新
SupervisoryCodeInfo supervisoryCodeInfo = equipmentCategoryMapper.searchSupervisoryBySupervisoryCode(supervisoryCode);
if (supervisoryCodeInfo != null && !ObjectUtils.isEmpty(supervisoryCodeInfo.getCode96333())) {
code96333 = supervisoryCodeInfo.getCode96333();
createStatus = NOT_CREATE;
} else {
// 2. 生成code96333
String prefix = "";
try {
prefix = this.cityCodeTo96333CodePrefix(city, county, isNotXixian);
} catch (Exception exception) {
log.error("cityCode转化地区初始码失败:{}", city);
log.error(exception.getMessage());
return;
}
code96333 = this.createElevatorCode(prefix);
createStatus = CREATE;
}
log.info("正在处理数据:{},96333码为:{},是否为新生成的96333:{}", record, code96333, "1".equals(createStatus) ? "是" : "否");
handlerDataNums.getAndSet(handlerDataNums.get() + 1);
handlerData.append(supervisoryCode).append(",");
// 更新数据库other_info 更新/新增码表
this.saveCode96333ForDataBase(supervisoryCode, createStatus, code96333, supervisoryCodeInfo);
// 更新es,索引:idx_biz_view_jg_all,idx_biz_equipment_info
this.saveCode96333ForEs(record, code96333);
});
return new JSONObject()
.fluentPut("总共异常数据:", exceptionData.size() + "条")
.fluentPut("程序处理数据条数:", handlerDataNums + "条")
.fluentPut("程序处理数据:", handlerData)
.fluentPut("异常数据,需手动处理:", JSONObject.toJSONString(manualProcessData));
}
private void saveCode96333ForEs(String record, String code96333) {
// idx_biz_view_jg_all
Optional<ESEquipmentCategoryDto> esEquipmentCategoryDto = esEquipmentCategory.findById(record);
esEquipmentCategoryDto.ifPresent(data -> {
data.setCODE96333(code96333);
esEquipmentCategory.save(data);
});
// idx_biz_equipment_info
Optional<ESEquipmentInfo> equipmentDaoById = esEquipmentDao.findById(record);
equipmentDaoById.ifPresent(data -> {
data.setCODE96333(code96333);
esEquipmentDao.save(data);
});
}
private void saveCode96333ForDataBase(String supervisoryCode, String createStatus, String code96333, SupervisoryCodeInfo supervisoryCodeInfo) {
if (supervisoryCodeInfo != null && !ObjectUtils.isEmpty(supervisoryCodeInfo.getSequenceNbr())) {
// 更新码表
supervisoryCodeInfoMapper.update(new SupervisoryCodeInfo().setCode96333(code96333),
new LambdaQueryWrapper<SupervisoryCodeInfo>()
.eq(SupervisoryCodeInfo::getSupervisoryCode, supervisoryCode));
} else {
// 新增码表
supervisoryCodeInfoMapper.insert(new SupervisoryCodeInfo()
.setCode96333(code96333)
.setSupervisoryCode(supervisoryCode)
.setStatus(EquipmentCategoryEnum.YSY.getCode())
.setCreateStatus(createStatus)
);
}
// otherInfo 表
IdxBizJgOtherInfo otherInfo = idxBizJgOtherInfoMapper.selectOne(
new LambdaQueryWrapper<IdxBizJgOtherInfo>()
.eq(IdxBizJgOtherInfo::getSupervisoryCode, supervisoryCode)
);
if (otherInfo != null) {
otherInfo.setCode96333(code96333);
idxBizJgOtherInfoService.update(otherInfo,
new LambdaQueryWrapper<IdxBizJgOtherInfo>().eq(IdxBizJgOtherInfo::getSupervisoryCode, supervisoryCode)
);
}
}
// 对应关系转化
// city --> EquipmentCategoryEnum.code --> EquipmentCategoryEnum.value
private String cityCodeTo96333CodePrefix(String city, String county, String isNotXixian) {
String code = EquipmentCategoryEnum.getCityCode.get(city);
if (StringUtils.isEmpty(code)) {
throw new RuntimeException("未匹配到对应的cityCode:" + city);
}
// 西咸
if (XIAN.equals(city) && "0".equals(isNotXixian)) {
return EquipmentCategoryEnum.XXCSM.getValue();
}
// 杨陵
if (YANG_LING.equals(county)) {
return EquipmentCategoryEnum.YLCSM.getValue();
}
// 韩城
if (HAN_CHENG.equals(county)) {
return EquipmentCategoryEnum.HCCSM.getValue();
}
// 神木
if (SHEN_MU.equals(county)) {
return EquipmentCategoryEnum.SMCSM.getValue();
}
// 府谷
if (FU_GU.equals(county)) {
return EquipmentCategoryEnum.FGCSM.getValue();
}
return EquipmentCategoryEnum.getValueByCode(code);
}
}
\ 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