Commit 40b684cc authored by 韩桐桐's avatar 韩桐桐

导出功能能:设备,使用登记证,企业

parent 7d6694ba
package com.yeejoin.amos.boot.biz.common.dto;
import lombok.Getter;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.Files;
@Getter
public class ByteArrayMultipartFile implements MultipartFile {
private byte[] bytes;
private String name;
private String originalFilename;
private String contentType;
public ByteArrayMultipartFile() {
}
public ByteArrayMultipartFile(String name, String originalFilename, String contentType, byte[] bytes) {
super();
this.name = name;
this.originalFilename = originalFilename;
this.contentType = contentType;
this.bytes = bytes;
}
@Override
public boolean isEmpty() {
return bytes.length == 0;
}
@Override
public long getSize() {
return bytes.length;
}
@Override
public InputStream getInputStream() {
return new ByteArrayInputStream(bytes);
}
@Override
public void transferTo(File destination) throws IOException {
try (OutputStream outputStream = Files.newOutputStream(destination.toPath())) {
outputStream.write(bytes);
}
}
}
......@@ -2,13 +2,16 @@ package com.yeejoin.amos.boot.biz.common.excel;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.yeejoin.amos.boot.biz.common.dto.ByteArrayMultipartFile;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
......@@ -16,9 +19,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
......@@ -31,6 +32,53 @@ public class ExcelUtil {
private static final Integer DUTY_CAR_START_INDEX = 5;
public static MultipartFile createTemplateExcelFile(String fileName,
String sheetName,
List<? extends Object> data,
Class<?> model,
DataSources dataDictionaryMapper,
boolean flag) {
// 设置单元格样式策略
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
// 用于存储下拉列表约束的Map
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
// 如果flag为true,处理模型类中的显式约束注解
if (flag) {
Field[] declaredFields = model.getDeclaredFields();
for (Field field : declaredFields) {
ExplicitConstraint explicitConstraint = field.getAnnotation(ExplicitConstraint.class);
resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint, dataDictionaryMapper);
}
}
// 创建Excel写入器
ExcelWriter excelWriter = EasyExcel.write(out, model)
.excelType(ExcelTypeEnum.XLSX)
.registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy)
.build();
// 创建工作表
WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).build();
excelWriter.write(data, writeSheet);
excelWriter.finish();
return new ByteArrayMultipartFile(fileName, // 文件名
fileName + ".xlsx", // 原始文件名
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // Content-Type
out.toByteArray());
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("生成Excel模板失败", e);
}
}
/**
* 生成excel模板
*
......
package com.yeejoin.amos.boot.biz.common.utils;
import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Objects;
......@@ -40,4 +41,42 @@ public class CommonUtils {
Object value = method.invoke(o, new Object[]{});
return value;
}
/**
* 深度copyJSONObjet ,用于多个jsonobjectg合并
* @param source
* @param target
* @return
*/
public static JSONObject deepMergeJSONObject(JSONObject source, JSONObject target) {
if (target == null) return source;
for (String key : source.keySet()) {
Object value = source.get(key);
if (!target.containsKey(key)) {
target.put(key, value); // 直接添加新键
} else {
// 若值为 JSONObject,递归合并
if (value instanceof JSONObject) {
deepMergeJSONObject((JSONObject) value, target.getJSONObject(key));
}
// 若值为 JSONArray,需处理数组合并(如叠加元素)
else if (value instanceof com.alibaba.fastjson.JSONArray) {
com.alibaba.fastjson.JSONArray srcArr = (com.alibaba.fastjson.JSONArray) value;
com.alibaba.fastjson.JSONArray tgtArr = target.getJSONArray(key);
for (Object item : srcArr) {
if (item instanceof JSONObject) {
// 若数组元素为对象,可递归合并(需匹配逻辑)
tgtArr.add(item); // 简单追加示例
} else {
tgtArr.add(item); // 基础类型直接添加
}
}
}
else {
target.put(key, value); // 非对象/数组则覆盖
}
}
}
return target;
}
}
......@@ -20,15 +20,16 @@ public class NameUtils {
* @return 转换后的字符串
*/
public static String underline2Camel(String line, boolean... smallCamel) {
if (line == null || "".equals(line)) {
if (line == null || line.isEmpty()) {
return "";
}
// 如果包含下划线,执行下划线转驼峰逻辑
if (line.contains("_")) {
StringBuffer sb = new StringBuffer();
Matcher matcher = NUMBER_PATTERN.matcher(line);
//匹配正则表达式
while (matcher.find()) {
String word = matcher.group();
//当是true 或则是空的情况
if ((smallCamel.length == 0 || smallCamel[0]) && matcher.start() == 0) {
sb.append(Character.toLowerCase(word.charAt(0)));
} else {
......@@ -44,6 +45,20 @@ public class NameUtils {
return sb.toString();
}
// 如果没有下划线但是全大写(例如 STOREY),按驼峰规则转换
if (line.equals(line.toUpperCase())) {
if (smallCamel.length == 0 || smallCamel[0]) {
return line.substring(0, 1).toLowerCase() + line.substring(1).toLowerCase();
} else {
return line.substring(0, 1).toUpperCase() + line.substring(1).toLowerCase();
}
}
// 否则(已是驼峰格式等),直接返回
return line;
}
/**
* 驼峰法转下划线
*
......
package com.yeejoin.amos.boot.biz.common.utils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
public class RequestContextWrapper {
private final String appKey;
private final String product;
private final String token;
private final String exeUserId;
private RequestContextWrapper(String appKey, String product, String token, String exeUserId) {
this.appKey = appKey;
this.product = product;
this.token = token;
this.exeUserId = exeUserId;
}
/**
* 捕获当前线程上下文
* @return RequestContextWrapper
*/
public static RequestContextWrapper capture() {
return new RequestContextWrapper(
RequestContext.getAppKey(),
RequestContext.getProduct(),
RequestContext.getToken(),
RequestContext.getExeUserId()
);
}
/**
* 应用上下文到目标线程
*/
public void apply() {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
RequestContext.setExeUserId(exeUserId);
}
}
\ No newline at end of file
......@@ -275,7 +275,7 @@ public class TzBaseEnterpriseInfoController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "企业信息列表数据导出", notes = "企业信息列表数据导出")
@ApiOperation(httpMethod = "GET", value = "企业信息列表数据导出-废弃-整合到jg服务,统一导出", notes = "企业信息列表数据导出-废弃-整合到jg服务,统一导出")
public void baseEnterpriseExport(HttpServletResponse response, String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
iTzBaseEnterpriseInfoService.export(response, ids, tzBaseEnterpriseInfoDto);
}
......
......@@ -623,12 +623,14 @@ public class TzBaseEnterpriseInfoServiceImpl
}
/**
* 整合到jg服务,统一导出
* 企业信息列表数据导出
*
* @param response 响应
* @param ids 数据id
*/
@Override
@Deprecated
public void export(HttpServletResponse response, String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
List<BaseEnterpriseVo> exportData;
if (StringUtils.isEmpty(ids)) { // 前端不选行,导出列表所有的数据
......
package com.yeejoin.amos.boot.module.jg.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 配合DictUtil.dictCode2DictName(xx)方法实现 字典值转换
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DictCode2DictName {
/**
* 字典类型
*/
String type() default "";
/**
* 对应处理类的bean名称
*/
String typeHandler() default "";
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yeejoin.amos.boot.module.jg.api.annotation.DictCode2DictName;
import lombok.Data;
import java.util.Date;
/**
* 企业信息
*/
@Data
public class BaseEnterpriseVo {
@ExcelProperty(value = "单位类型")
String unitType;
@ExcelProperty(value = "单位统一信用代码")
String useCode;
@ExcelProperty(value = "单位名称")
String useUnit;
@ExcelProperty(value = "监管系统唯一编码")
String superviseCode;
@ExcelProperty(value = "使用单位证件类型")
String useUnitCertificate;
@ExcelProperty(value = "监管机构组织机构代码")
String superviseOrgCode;
@ExcelProperty(value = "监管机构名称")
String superviseOrgName;
@ExcelProperty(value = "单位所在省份名称")
String province;
@ExcelProperty(value = "单位所在城市名称")
String city;
@ExcelProperty(value = "单位所在区县名称")
String district;
@ExcelProperty(value = "单位所在街道名称")
String street;
@ExcelProperty(value = "单位所在社区名称")
String community;
@ExcelProperty(value = "单位详细地址")
String address;
@ExcelProperty(value = "使用单位法人")
String legalPerson;
@ExcelProperty(value = "法人联系电话")
String legalPhone;
@ExcelProperty(value = "使用单位联系人")
String useContact;
@ExcelProperty(value = "联系人联系电话")
String contactPhone;
@ExcelProperty(value = "管辖机构")
String governingBody;
@ExcelProperty(value = "所属行业")
String industry;
@ExcelProperty(value = "登记机关")
String registrationAuthority;
@ExcelProperty(value = "核准时间")
Date approvalTime;
@ExcelProperty(value = "经营状态")
String operatingStatus;
@ExcelProperty(value = "涉及设备类型")
String equipCategory;
@ExcelProperty(value = "行业主管部门")
@DictCode2DictName(type = "HYZGBM", typeHandler = "cbDataDictTypeHandler")
String industrySupervisor;
@ExcelProperty(value = "注册类型")
String registerType;
@ExcelProperty("证书类型")
String certType;
@ExcelProperty("证书编号(核准证编号)")
String certNo;
@JsonFormat(pattern = "yyyy-MM-dd")
@ExcelProperty("有效期至")
Date expiryDate;
@JsonFormat(pattern = "yyyy-MM-dd")
@ExcelProperty("发证日期")
Date issueDate;
@JsonFormat(pattern = "yyyy-MM-dd")
@ExcelProperty("变更日期")
Date changeDate;
@ExcelProperty("许可方式/许可状态")
String applyType;
@ExcelProperty("备注")
String remark;
@ExcelProperty("许可项目/检验类型/设备品种(核准项目名称)")
String itemCodeName;
@ExcelProperty("许可子项目/检验项目/充装介质类别")
String subItemName;
@ExcelProperty("许可参数/充装介质名称")
String parameter;
@ExcelProperty("固定检验地址")
String itemAddress;
@ExcelProperty("发证机关")
String approvedOrgan;
}
package com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.jg.api.annotation.DictCode2DictName;
import lombok.Data;
/**
......@@ -9,36 +11,72 @@ import lombok.Data;
@Data
public class CertificateVo {
@ExcelProperty(value = "使用登记证编号", index = 0)
@ExcelIgnore
String sequenceNbr;
@ExcelProperty(value = "使用登记证编号")
String useRegistrationCode;
@ExcelProperty(value = "登记类型", index = 1)
@ExcelProperty(value = "登记类型")
String regType;
@ExcelProperty(value = "使用单位", index = 2)
@ExcelProperty(value = "使用单位")
String useUnitName;
@ExcelProperty(value = "使用单位地址", index = 3)
@ExcelProperty(value = "使用单位地址")
String useUnitAddress;
@ExcelProperty(value = "登记机关", index = 4)
@ExcelProperty(value = "登记机关")
String receiveOrgName;
@ExcelProperty(value = "设备种类", index = 5)
@ExcelProperty(value = "设备种类")
@DictCode2DictName(typeHandler = "equipCategoryDictTypeHandler")
String equList;
@ExcelProperty(value = "设备类别", index = 6)
@ExcelProperty(value = "设备类别")
@DictCode2DictName(typeHandler = "equipCategoryDictTypeHandler")
String equCategory;
@ExcelProperty(value = "设备品种", index = 7)
@ExcelProperty(value = "设备品种")
@DictCode2DictName(typeHandler = "equipCategoryDictTypeHandler")
String equDefine;
@ExcelProperty(value = "设备使用地址", index = 8)
@ExcelProperty(value = "设备使用地址")
String equUseAddress;
@ExcelProperty(value = "使用登记证状态", index = 9)
@ExcelProperty(value = "使用登记证状态")
String certificateStatus;
@ExcelProperty(value = "办理日期", index = 10)
@ExcelProperty(value = "办理日期")
String auditPassDate;
@ExcelProperty(value = "产品名称")
String productName;
@ExcelProperty(value = "产品编号")
String factoryNum;
@ExcelProperty(value = "单位内编号")
String useInnerCode;
@ExcelProperty(value = "设备代码")
String equCode;
@ExcelProperty(value = "监管码")
String supervisoryCode;
@ExcelProperty(value = "设备状态")
String equStateName;
@ExcelProperty(value = "工程(装置)名称")
String projectContraption;
@ExcelProperty(value = "工程(装置)编号")
String projectContraptionNo;
@ExcelProperty(value = "管道设备数量(m)")
String pipelineLength;
@ExcelProperty(value = "管道使用地点")
String fullAddress;
}
package com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.jg.api.annotation.DictCode2DictName;
import lombok.Data;
/**
* 管道已纳管设备
*/
@Data
public class PipeEquipmentVo {
@ExcelProperty(value = "工程(装置)编号/项目编号")
String projectContraptionNo;
@ExcelProperty(value = "工程(装置)名称/项目名称")
String projectContraption;
@ExcelProperty(value = "设备种类")
String equListName;
@ExcelProperty(value = "设备类别")
String equCategoryName;
@ExcelProperty(value = "设备品种")
String equDefineName;
@ExcelProperty(value = "使用单位名称")
String useUnitName;
@ExcelProperty(value = "使用登记证")
String useRegistrationCode;
@ExcelProperty(value = "属地监管部门")
String orgName;
@ExcelProperty(value = "监管码")
String supervisoryCode;
@ExcelProperty(value = "投入年月")
String useDate;
@ExcelProperty(value = " 设备使用地点省")
@DictCode2DictName(typeHandler = "regionCodeTypeHandler")
String province;
@ExcelProperty(value = " 设备使用地点市")
@DictCode2DictName(typeHandler = "regionCodeTypeHandler")
String city;
@ExcelProperty(value = "设备使用地点区(县)")
@DictCode2DictName(typeHandler = "regionCodeTypeHandler")
String county;
@ExcelProperty(value = "设备使用地点街道(镇)")
@DictCode2DictName(typeHandler = "regionCodeTypeHandler")
String street;
@ExcelProperty(value = "设备详细使用地点")
String address;
@ExcelProperty(value = "管道编号")
String pipelineNumber;
@ExcelProperty(value = "管道名称(登记单元)")
String pipeName;
@ExcelProperty(value = "设计单位")
String designUnitName;
@ExcelProperty(value = "设计-压力(MPa)")
String pressure;
@ExcelProperty(value = "设计-介质")
String medium;
@ExcelProperty(value = "设计-温度(℃)")
String temperature;
@ExcelProperty(value = "工作条件-温度(℃)")
String workTemperature;
@ExcelProperty(value = "检验/检测机构名称")
String inspectOrgName;
@ExcelProperty(value = "安装单位")
String uscUnitName;
@ExcelProperty(value = "安装年月")
String uscDate;
@ExcelProperty(value = "工作条件-压力(MPa)")
String workPressure;
@ExcelProperty(value = "检验结论")
@DictCode2DictName(type = "JYJL", typeHandler = "cbDataDictTypeHandler")
String inspectConclusion;
@ExcelProperty(value = "下次检验日期")
String nextInspectDate;
@ExcelProperty(value = "管道规格-管道长度(m)")
String pipeLength;
@ExcelProperty(value = "管道级别")
@DictCode2DictName(type = "GYGDHIS", typeHandler = "cbDataDictTypeHandler")
String deviceLevel;
@ExcelProperty(value = "工作条件-介质")
String workMedium;
@ExcelProperty(value = "管道规格-公称直径(mm)")
String nominalDiameter;
@ExcelProperty(value = "管道规格-公称壁厚(mm)")
String wallThickness;
@ExcelProperty(value = "备注")
String remarks;
}
......@@ -97,14 +97,10 @@ public class IdxBizJgProjectContraptionController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "根据入参 分页查询(当前)单位下的工程管道", notes = "根据入参 分页查询(当前)单位下的工程管道")
public ResponseModel<IPage<IdxBizJgProjectContraption>> proConPageByParams(
@RequestParam Map<String, String> params,
@RequestParam(value = "sort",required = false) String sort,
@RequestParam(value = "sort", required = false) String sort,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<IdxBizJgProjectContraption> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(idxBizJgProjectContraptionServiceImpl.proConPageByParams(sort,params, page, reginParams));
return ResponseHelper.buildResponse(idxBizJgProjectContraptionServiceImpl.proConPageByParams(current, size, sort, params, getSelectedOrgInfo()));
}
......
......@@ -86,14 +86,7 @@ public class IdxBizJqEquipmentRegisterController extends BaseController {
@GetMapping(value = "/{record}")
@ApiOperation(httpMethod = "GET", value = "根据record查询设备注册信息详情", notes = "根据record查询设备注册信息详情")
public ResponseModel<Object> selectOne(@PathVariable String record, @RequestParam(required = false) String isCopy) {
CompanyBo companyBo = getSelectedOrgInfo().getCompany();
String companyLevel;
if(companyBo.getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)){
companyLevel = companyBo.getLevel();
} else {
companyLevel = BaseController.COMPANY_TYPE_SUPERVISION;
}
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.getEquipmentRegisterByRecord(record, isCopy, companyLevel));
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.getEquipmentRegisterByRecord(record, isCopy));
}
......
......@@ -149,19 +149,7 @@ public class JgUseRegistrationManageController extends BaseController {
@RequestParam(value = "sort", required = false) String sort,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<JgUseRegistrationManageDto> page = new Page<JgUseRegistrationManageDto>();
page.setCurrent(current);
page.setSize(size);
ReginParams info = getSelectedOrgInfo();
if (info.getCompany().getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
dto.setDataType(BaseController.COMPANY_TYPE_COMPANY);
dto.setUseUnitCreditCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(info.getCompany().getCompanyType()) ?
info.getCompany().getCompanyCode().split("_")[1] : info.getCompany().getCompanyCode());
} else {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
dto.setReceiveCompanyCode(info.getCompany().getCompanyCode());
}
dto.setIsDoBusiness(ValidationUtil.isEmpty(dto.getIsDoBusiness()) ? "1" : "");
Page<JgUseRegistrationManageDto> page = jgUseRegistrationManageServiceImpl.buildFilter(dto, current, size);
return ResponseHelper.buildResponse(jgUseRegistrationManageServiceImpl.queryForJgUseRegistrationManagePage(page, dto, sort));
}
......
package com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.typeHandler.DictTypeHandler;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* 业务字典处理器
*/
@Component("equipCategoryDictTypeHandler")
@RequiredArgsConstructor
public class EquipCategoryDictTypeHandler implements DictTypeHandler {
private final EquipmentCategoryMapper equipmentCategoryMapper;;
private final Map<String, String> cache = new ConcurrentHashMap<>();
// dictType 未用到
@Override
public String handle(String dictType, String dictCode) {
if (StringUtils.isEmpty(dictCode)) {
return null;
}
// 汉字不做转化
if (!dictCode.isEmpty() && dictCode.matches("^[\\u4e00-\\u9fa5]+$")){
return dictCode;
}
return cache.computeIfAbsent(dictCode, (k) -> {
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory::getCode, dictCode);
EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(wrapper);
return Optional.ofNullable(equipmentCategory).map(EquipmentCategory::getName).orElse(null);
});
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler;
import com.yeejoin.amos.boot.biz.common.typeHandler.DictTypeHandler;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
* 平台维护的字典处理器
*/
@Slf4j
@Component("platformDictTypeHandler")
@RequiredArgsConstructor
public class PlatformDictTypeHandler implements DictTypeHandler {
private final Map<String, String> cache = new ConcurrentHashMap<>();
@Override
public String handle(String dictType, String dictCode) {
if (StringUtils.isEmpty(dictCode)){
return null;
}
return cache.computeIfAbsent(dictCode, k -> {
try {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues(dictType).getResult();
return result.stream()
.filter(Objects::nonNull)
.filter(dict -> dict.getDictDataKey() != null && dict.getDictDataKey().equals(dictCode))
.findFirst()
.map(DictionarieValueModel::getDictDataValue)
.orElse(null);
} catch (Exception e) {
log.error("获取字典数据失败,dictType: {}, error: {}", dictType, e.getMessage(), e);
return null;
}
});
}
}
package com.yeejoin.amos.boot.module.jg.biz.feign;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@FeignClient(name = "TZS-JCZS", path = "/jczs", configuration = {FeignConfiguration.class})
public interface JczsServiceFeignClient {
/**
* 企业信息列表分页查询
*/
@RequestMapping(value = "/baseEnterprise/page", method = RequestMethod.GET)
ResponseModel<Page<TzBaseEnterpriseInfoDto>> page(@RequestParam("page") int page,
@RequestParam("size") int size,
@RequestParam("keyword") String keyword,
@RequestBody TzBaseEnterpriseInfoDto dto);
}
......@@ -21,7 +21,7 @@ public interface IIdxBizJgProjectContraptionService extends IService<IdxBizJgPro
Boolean deleteProjectAndEquInfoBySeq(Long sequenceNbr);
IPage<IdxBizJgProjectContraption> proConPageByParams(String sort, Map<String, String> params, Page<IdxBizJgProjectContraption> page, ReginParams reginParams);
IPage<IdxBizJgProjectContraption> proConPageByParams(int current, int size, String sort, Map<String, String> params, ReginParams reginParams);
List<IdxBizJgProjectContraption> proConListByParams(Map<String, String> params, ReginParams reginParams);
......
......@@ -22,7 +22,7 @@ public interface IIdxBizJgRegisterInfoService {
boolean batchDeleteByRecord(Map<String,Object> map);
Map<String, Map<String, Object>> getEquipmentRegisterByRecord(String record, String isCopy, String companyLevel);
Map<String, Map<String, Object>> getEquipmentRegisterByRecord(String record, String isCopy);
Page<JSONObject> queryForEquipmentRegisterPage(JSONObject jsonObject);
......
package com.yeejoin.amos.boot.module.jg.biz.service;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationManageDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* JG表格数据导出接口类
*/
public interface IJgTableDataExportService {
void gen(String jsonName, String voName,String tableName);
void gen(String jsonName, String voName, String tableName);
void certificate(HttpServletResponse response, List<String> ids);
void certificate(ReginParams reginParams, JgUseRegistrationManageDto dto, List<String> ids, String sort);
void maintenance(HttpServletResponse response, List<String> ids);
......@@ -43,10 +47,15 @@ public interface IJgTableDataExportService {
void changeVehicleRegistrationUnit(HttpServletResponse response, List<String> ids);
void unregulatedEquip(HttpServletResponse response, List<String> ids);
void unregulatedEquip(ReginParams reginParams, Map<String, Object> map);
void manageEquipment(HttpServletResponse response, List<String> ids);
void manageEquipment(ReginParams reginParams, Map<String, Object> map);
void equipTransfer(HttpServletResponse response, List<String> ids);
void managePipe(Map<String, String> params, String sort, ReginParams reginParams);
void unregulatedPipe(Map<String, String> params, String sort, ReginParams reginParams);
void enterpriseInformationExport(String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto, ReginParams reginParams);
}
......@@ -19,6 +19,7 @@ import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
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.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
......@@ -129,6 +130,8 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
private DataDictionaryServiceImpl dataDictionaryServiceImpl;
@Autowired
private RedisUtils redisUtils;
@Autowired
private JgUseRegistrationManageServiceImpl registrationManageService;
@Override
public boolean saveOrUpdateData(IdxBizJgProjectContraption projectContraption) {
......@@ -144,6 +147,34 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
}
/**
* 根据证的seq查询其下的工程装置
*/
public List<IdxBizJgProjectContraption> queryProConByCertSeq(String certSeq) {
JgUseRegistrationManage certManage = registrationManageService.getBaseMapper().selectById(certSeq);
List<IdxBizJgProjectContraption> result = this.lambdaQuery()
.eq(IdxBizJgProjectContraption::getIsDelete, Boolean.FALSE)
.isNull(IdxBizJgProjectContraption::getProjectContraptionParentId)
.eq(IdxBizJgProjectContraption::getUseRegistrationCode, certManage.getUseRegistrationCode())
.list();
if (!ValidationUtil.isEmpty(result)) {
result.forEach(record -> {
BigDecimal pipelineLength = BigDecimal.valueOf(record.getPipelineLength());
BigDecimal roundedValue = pipelineLength.setScale(3, RoundingMode.HALF_UP);
BigDecimal strippedValue = roundedValue.stripTrailingZeros();
record.setPipelineLength(Double.valueOf(strippedValue.toPlainString()));
record.setDataSourceName(EquipSourceEnum.getDataSourceName(record.getDataSource()));
record.setFullAddress(
Stream.of(record.getProvinceName(), record.getCityName(), record.getCountyName(), record.getStreetName(), record.getAddress())
.map(value -> value == null ? "" : value)
.collect(Collectors.joining())
);
});
}
return result;
}
/**
* 根据工程装置seq物理删除装置表数据和对应设备信息(数据库+es)
*
* @param sequenceNbr 工程装置表seq
......@@ -179,12 +210,14 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
* 根据入参 分页查询(当前)单位下的工程管道
*
* @param params 查询参数 Map
* @param page 分页
* @param reginParams 当前登录人信息
* @return result
*/
@Override
public IPage<IdxBizJgProjectContraption> proConPageByParams(String sort, Map<String, String> params, Page<IdxBizJgProjectContraption> page, ReginParams reginParams) {
public IPage<IdxBizJgProjectContraption> proConPageByParams(int current, int size, String sort, Map<String, String> params, ReginParams reginParams) {
Page<IdxBizJgProjectContraption> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
CompanyBo company = reginParams.getCompany();
String companyType = company.getCompanyType();
String companyCode = company.getCompanyCode();
......
......@@ -21,10 +21,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
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.jg.api.dto.*;
......@@ -97,7 +94,7 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -300,16 +297,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
private TzsUserInfoMapper tzsUserInfoMapper;
@Autowired
private ShCarEquServiceImpl shCarEquService;
@Autowired
private ShCarServiceImpl shCarService;
@Autowired
private IIdxBizJgProjectContraptionService idxBizJgProjectContraptionService;
private IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService;
@Value("classpath:/json/urlInfo.json")
private Resource urlInfo;
@Autowired
private CommonServiceImpl commonServiceImpl;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
public IdxBizJgRegisterInfo getOneData(String record) {
return this.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record));
}
......@@ -1078,10 +1073,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
* 查询设备注册信息详情
*
* @param record
* @param companyLevel
* @return
*/
public Map<String, Map<String, Object>> getEquipmentRegisterByRecord(String record, String isCopy, String companyLevel) {
public Map<String, Map<String, Object>> getEquipmentRegisterByRecord(String record, String isCopy) {
CompanyBo companyBo = getSelectedOrgInfo().getCompany();
String companyLevel;
if(companyBo.getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)){
companyLevel = companyBo.getLevel();
} else {
companyLevel = BaseController.COMPANY_TYPE_SUPERVISION;
}
Map<String, Map<String, Object>> resultMap = new HashMap<>();
// 设备种类
Map<String, Object> equIpClassMap = this.getEquIpClassMap(record, "");
......@@ -4780,33 +4781,24 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
*/
public List<JSONObject> queryEquipInIds(List<String> ids) {
List<JSONObject> result = new ArrayList<>();
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(ids)) {
BoolQueryBuilder seqBuilder = QueryBuilders.boolQuery();
seqBuilder.must(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", ids));
boolMust.must(seqBuilder);
}
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
request.source(builder);
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
List<CompletableFuture<JSONObject>> futures = new ArrayList<>();
ids.forEach(record ->{
CompletableFuture<JSONObject> future = CompletableFuture.supplyAsync(() -> {
JSONObject itemJsonObject = new JSONObject();
contextWrapper.apply();
Map<String, Map<String, Object>> registerByRecord = idxBizJgRegisterInfoService.getEquipmentRegisterByRecord(record, "0");
registerByRecord.values().forEach(i -> CommonUtils.deepMergeJSONObject(new JSONObject(i),itemJsonObject));
return itemJsonObject;
}, executorService);
futures.add(future);
});
for (CompletableFuture<JSONObject> future : futures) {
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject source = jsonObject.getJSONObject("sourceAsMap");
if (!ValidationUtil.isEmpty(source.get(DATA_SOURCE))) {
String s = source.get(DATA_SOURCE).toString();
source.put(DATA_SOURCE, s);
source.put(DATA_SOURCE_NAME, EquipSourceEnum.getDataSourceName(s));
result.add(future.get());
} catch (InterruptedException | ExecutionException e) {
log.error("执行失败", e);
}
result.add(source);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
......@@ -5011,4 +5003,44 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
throw new RuntimeException(sendVerifyCodeResult.getMessage());
}
/**
* 根据工程装置ids设备数据
*/
public List<JSONObject> queryPipeEquipInIds(List<String> proConSeqs) {
List<JSONObject> result = new ArrayList<>();
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
List<CompletableFuture<JSONArray>> futures = new ArrayList<>();
proConSeqs.forEach(seq ->{
CompletableFuture<JSONArray> future = CompletableFuture.supplyAsync(() -> {
JSONArray resultArray = new JSONArray();
contextWrapper.apply();
Map<String, Map<String, Object>> details = idxBizJgProjectContraptionService.details(seq);
Map<String, Object> objectMap = details.get(EQUIP_INFO_FORM_ID);
JSONArray pipeList = JSON.parseArray(JSON.toJSONString(objectMap.get(PIPELINE_LIST)));
pipeList.forEach(pipeEqu -> {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(pipeEqu));
for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
if (!PIPELINE_LIST.equals(entry.getKey())) {
jsonObject.put(entry.getKey(), entry.getValue());
}
}
resultArray.add(jsonObject);
});
return resultArray;
}, executorService);
futures.add(future);
});
for (CompletableFuture<JSONArray> future : futures) {
try {
future.get().stream()
.filter(o -> o instanceof JSONObject)
.map(o -> (JSONObject) o)
.forEach(result::add);
} catch (InterruptedException | ExecutionException e) {
log.error("执行失败", e);
}
}
return result;
}
}
\ No newline at end of file
......@@ -7,15 +7,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
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.dto.FormValue;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationManageDto;
import com.yeejoin.amos.boot.module.jg.api.dto.UseFlagParamDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CertificateStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgUseRegistrationManageService;
......@@ -54,6 +55,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -150,6 +152,16 @@ public class JgUseRegistrationManageServiceImpl extends BaseService<JgUseRegistr
private static final long SCROLL_TIMEOUT = 180000;
private static final int SIZE = 1000;
@Autowired
private RedisUtils redisUtils;
/**
* 用户选择信心redis获取
**/
protected ReginParams getSelectedOrgInfo() {
return JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
}
/**
* 将已经通过使用登记审批的证信息录入到 jg-use-registration-manage 表中
......@@ -275,6 +287,23 @@ public class JgUseRegistrationManageServiceImpl extends BaseService<JgUseRegistr
return Boolean.TRUE;
}
public Page<JgUseRegistrationManageDto> buildFilter(JgUseRegistrationManageDto dto, int current, int size) {
Page<JgUseRegistrationManageDto> page = new Page<JgUseRegistrationManageDto>();
page.setCurrent(current);
page.setSize(size);
ReginParams info = getSelectedOrgInfo();
if (info.getCompany().getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
dto.setDataType(BaseController.COMPANY_TYPE_COMPANY);
dto.setUseUnitCreditCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(info.getCompany().getCompanyType()) ?
info.getCompany().getCompanyCode().split("_")[1] : info.getCompany().getCompanyCode());
} else {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
dto.setReceiveCompanyCode(info.getCompany().getCompanyCode());
}
dto.setIsDoBusiness(ValidationUtil.isEmpty(dto.getIsDoBusiness()) ? "1" : "");
return page;
}
/**
* 分页查询
......
package com.yeejoin.amos.boot.module.jg.biz.utils;
import cn.hutool.extra.spring.SpringUtil;
import com.yeejoin.amos.boot.biz.common.typeHandler.DictTypeHandler;
import com.yeejoin.amos.boot.biz.common.typeHandler.TypeHandler;
import com.yeejoin.amos.boot.module.jg.api.annotation.DictCode2DictName;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Objects;
@Slf4j
public class DictUtil {
/**
* 配合注解@DictCode2DictName(code="",type="")使用
* 将字段从dictCode转化为dictName
*
* @param data 需要转化的数据
*/
public static void dictCode2DictName(Object data) {
if (data == null) {
return;
}
// 处理 List 类型
if (data instanceof List<?>) {
List<?> list = (List<?>) data;
for (Object item : list) {
dictCode2DictName(item); // 递归处理每个元素
}
} else {
// 处理单个对象
Field[] fields = data.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
if (field.isAnnotationPresent(DictCode2DictName.class)) {
try {
DictCode2DictName annotation = field.getAnnotation(DictCode2DictName.class);
String code = Objects.toString(field.get(data));
String type = annotation.type();
String typeHandler = annotation.typeHandler();
String name = "";
Object handler = SpringUtil.getBean(typeHandler);
if (handler instanceof DictTypeHandler) {
name = ((DictTypeHandler) handler).handle(type, code);
} else if (handler instanceof TypeHandler) {
name = Objects.toString(((TypeHandler) handler).handle(code));
} else {
log.warn("未识别的 handler 类型:{}", handler.getClass().getName());
}
field.set(data, name);
} catch (IllegalAccessException | IllegalArgumentException e) {
log.error("字段赋值失败: {}, 类型: {}", field.getName(), data.getClass().getName(), e);
}
}
}
}
}
}
......@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 企业数据信息 Mapper 接口
......@@ -104,4 +105,7 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
* @return TzBaseEnterpriseInfo
*/
TzBaseEnterpriseInfo selectByUseUnitCode(String useUnitCode);
List<Map<String,String>> getEnterInfoWithExport(@Param("ids") List<String> ids);
}
......@@ -374,4 +374,18 @@
<select id="selectByUseUnitCode" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo">
select * from tz_base_enterprise_info where use_unit_code = #{useUnitCode}
</select>
<select id="getEnterInfoWithExport" resultType="java.util.Map">
select *
from amos_tzs_biz.tz_base_enterprise_info tbei
left join amos_tzs_biz.tz_base_unit_licence tbul on tbei."use_unit_code" = tbul."unit_code"
<where>
<if test='ids != null'>
and tbei.sequence_nbr in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
</mapper>
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