Commit 5532efce authored by 韩桐桐's avatar 韩桐桐

导出BUGFIX

parent d20161be
......@@ -189,8 +189,9 @@ public class TzBaseEnterpriseInfoController {
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel<IPage<TzBaseEnterpriseInfoDto>> page(PageParam pageParam,
@RequestParam(value = "sort", required = false) String sort,
TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
return ResponseHelper.buildResponse(iTzBaseEnterpriseInfoService.page(pageParam, tzBaseEnterpriseInfoDto,sort));
@RequestParam Map<String, String> map) {
TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto = JSON.parseObject(JSON.toJSONString(map), TzBaseEnterpriseInfoDto.class);
return ResponseHelper.buildResponse(iTzBaseEnterpriseInfoService.page(pageParam, tzBaseEnterpriseInfoDto, sort));
}
......
......@@ -126,6 +126,13 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "检验/检测人员名称")
String inspectStaff;
@ExcelProperty(value = "检验/检测日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String inspectDate;
@ExcelProperty(value = "下次检验/检测日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String nextInspectDate;
@ExcelProperty(value = "制造单位统一社会信用代码")
String produceUnitCreditCode;
......@@ -136,6 +143,10 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "制造许可编号")
String produceLicenseNum;
@ExcelProperty(value = "制造日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String produceDate;
@ExcelProperty(value = "制造国")
String produceCountry;
......@@ -157,6 +168,14 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "设计文件鉴定单位")
String appraisalUnit;
@ExcelProperty(value = "设计日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String designDate;
@ExcelProperty(value = "设计文件鉴定日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String appraisalDate;
@ExcelProperty(value = "安装单位")
String installPropertyUnitName;
......@@ -169,6 +188,10 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "安装地点")
String installAddress;
@ExcelProperty(value = "安装日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String installStartDate;
@ExcelProperty(value = "维保单位")
String meUnitName;
......@@ -191,6 +214,14 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "安装负责人联系电话")
String installLeaderPhone;
@ExcelProperty(value = "维保合同开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String informStart;
@ExcelProperty(value = "维保合同结束日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String informEnd;
@ExcelProperty(value = "维保人员一")
String meMaster;
......@@ -206,56 +237,6 @@ public class ManageEquipmentVo {
@ExcelProperty(value = "备注")
String informationManageCode;
// @ExcelProperty(value = "检验/检测日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String inspectDate;
// @ExcelProperty(value = "制造日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String produceDate;
// @ExcelProperty(value = "安装日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String installStartDate;
// @ExcelProperty(value = "设计日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String designDate;
// @ExcelProperty(value = "设计文件鉴定日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String appraisalDate;
// @ExcelProperty(value = "延期使用年限日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String delayServiceLifeDate;
// @ExcelProperty(value = "维保合同结束日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String informEnd;
// @ExcelProperty(value = "维保合同开始日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String informStart;
// @ExcelProperty(value = "下次检验/检测日期", 72)
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String nextInspectDate;
@ExcelProperty(value = "门数")
String numberDoors;
......
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;
......@@ -39,6 +40,7 @@ public class PipeEquipmentVo {
String supervisoryCode;
@ExcelProperty(value = "投入年月")
@JsonFormat(pattern = "yyyy-MM")
String useDate;
@ExcelProperty(value = " 设备使用地点省")
......@@ -88,6 +90,7 @@ public class PipeEquipmentVo {
String uscUnitName;
@ExcelProperty(value = "安装年月")
@JsonFormat(pattern = "yyyy-MM")
String uscDate;
@ExcelProperty(value = "工作条件-压力(MPa)")
......@@ -98,6 +101,7 @@ public class PipeEquipmentVo {
String inspectConclusion;
@ExcelProperty(value = "下次检验日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String nextInspectDate;
@ExcelProperty(value = "管道规格-管道长度(m)")
......
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;
......@@ -122,6 +123,13 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "检验/检测人员名称")
String inspectStaff;
@ExcelProperty(value = "检验/检测日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String inspectDate;
@ExcelProperty(value = "下次检验/检测日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String nextInspectDate;
@ExcelProperty(value = "制造单位统一社会信用代码")
String produceUnitCreditCode;
......@@ -132,6 +140,10 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "制造许可编号")
String produceLicenseNum;
@ExcelProperty(value = "制造日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String produceDate;
@ExcelProperty(value = "制造国")
String produceCountry;
......@@ -153,6 +165,14 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "设计文件鉴定单位")
String appraisalUnit;
@ExcelProperty(value = "设计日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String designDate;
@ExcelProperty(value = "设计文件鉴定日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String appraisalDate;
@ExcelProperty(value = "安装单位")
String installPropertyUnitName;
......@@ -165,6 +185,10 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "安装地点")
String installAddress;
@ExcelProperty(value = "安装日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String installStartDate;
@ExcelProperty(value = "维保单位")
String meUnitName;
......@@ -187,6 +211,14 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "安装负责人联系电话")
String installLeaderPhone;
@ExcelProperty(value = "维保合同开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String informStart;
@ExcelProperty(value = "维保合同结束日期")
@JsonFormat(pattern = "yyyy-MM-dd")
String informEnd;
@ExcelProperty(value = "维保人员一")
String meMaster;
......@@ -202,56 +234,6 @@ public class UnregulatedEquipVo {
@ExcelProperty(value = "备注")
String informationManageCode;
// @ExcelProperty(value = "检验/检测日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String inspectDate;
// @ExcelProperty(value = "制造日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String produceDate;
// @ExcelProperty(value = "安装日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String installStartDate;
// @ExcelProperty(value = "设计日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String designDate;
// @ExcelProperty(value = "设计文件鉴定日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String appraisalDate;
// @ExcelProperty(value = "延期使用年限日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String delayServiceLifeDate;
// @ExcelProperty(value = "维保合同结束日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String informEnd;
// @ExcelProperty(value = "维保合同开始日期")
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String informStart;
// @ExcelProperty(value = "下次检验/检测日期", 72)
// @JsonFormat(pattern = "yyyy-MM-dd")
// @JsonSerialize(using = BizCustomDateSerializer.class)
// String nextInspectDate;
@ExcelProperty(value = "门数")
String numberDoors;
......
......@@ -260,13 +260,14 @@ public class JgTableDataExportController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/enterpriseInformationExport")
@ApiOperation(httpMethod = "GET", value = "基础设置-企业信息列表数据导出", notes = "基础设置-企业信息列表数据导出")
public ResponseModel<String> managePipe(String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
public ResponseModel<String> managePipe(@RequestParam(value = "ids", required = false) String ids,
@RequestParam Map<String, String> map) {
String uuid = UUID.randomUUID().toString();
iJgTableDataExportService.startDownLoadMsg("企业信息列表", uuid);
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
new Thread(() -> {
contextWrapper.apply();
iJgTableDataExportService.enterpriseInformationExport(uuid, ids, tzBaseEnterpriseInfoDto);
iJgTableDataExportService.enterpriseInformationExport(uuid, ids, map);
}).start();
return ResponseHelper.buildResponse("后台处理中,请注意下载!");
}
......
......@@ -3,14 +3,14 @@ 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;
import java.util.Map;
@FeignClient(name = "TZS-JCZS", path = "/jczs", configuration = {FeignConfiguration.class})
public interface JczsServiceFeignClient {
......@@ -18,9 +18,9 @@ public interface JczsServiceFeignClient {
* 企业信息列表分页查询
*/
@RequestMapping(value = "/baseEnterprise/page", method = RequestMethod.GET)
ResponseModel<Page<TzBaseEnterpriseInfoDto>> page(@RequestParam("page") int page,
ResponseModel<Page<Map<String, String>>> page(@RequestParam("page") int page,
@RequestParam("size") int size,
@RequestParam("keyword") String keyword,
@RequestBody TzBaseEnterpriseInfoDto dto);
@RequestParam Map<String, String> map);
}
......@@ -59,7 +59,7 @@ public interface IJgTableDataExportService {
void unregulatedPipe(String uuid, Map<String, String> params, String sort, ReginParams reginParams);
void enterpriseInformationExport(String uuid, String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto);
void enterpriseInformationExport(String uuid, String ids, Map<String, String> map);
void userInfoExport(String uuid, String ids, Map<String, String> map);
......
......@@ -5047,6 +5047,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
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)));
// 列表有条数据,详情没有管道信息的情况
if (pipeList.isEmpty()) {
JSONObject jsonObject = new JSONObject();
for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
if (!PIPELINE_LIST.equals(entry.getKey())) {
jsonObject.put(entry.getKey(), entry.getValue());
}
}
resultArray.add(jsonObject);
}
pipeList.forEach(pipeEqu -> {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(pipeEqu));
for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
......
......@@ -756,16 +756,16 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
.fluentPut("time", new Date().getTime()));
}
private List<String> getEnterSeqs(String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
private List<String> getEnterSeqs(String ids, Map<String, String> map) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
List<String> idsList = new ArrayList<>();
if (StringUtils.isEmpty(ids)) {
ResponseModel<Page<TzBaseEnterpriseInfoDto>> page = jczsServiceFeignClient.page(1, PAGE_SIZE, null, tzBaseEnterpriseInfoDto);
Page<TzBaseEnterpriseInfoDto> pageResult = page.getResult();
ResponseModel<Page<Map<String, String>>> page = jczsServiceFeignClient.page(1, PAGE_SIZE, null, map);
Page<Map<String, String>> pageResult = page.getResult();
int totalPage = (int) Math.ceil((double) pageResult.getTotal() / PAGE_SIZE);
List<CompletableFuture<List<String>>> futures = new ArrayList<>();
List<String> idsCollected = pageResult.getRecords().stream()
.map(BaseDto::getSequenceNbr)
.map(item -> item.getOrDefault("sequenceNbr", ""))
.map(String::valueOf)
.collect(Collectors.toList());
......@@ -773,10 +773,10 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
int pageIndex = i;
CompletableFuture<List<String>> future = CompletableFuture.supplyAsync(() -> {
contextWrapper.apply();
ResponseModel<Page<TzBaseEnterpriseInfoDto>> page1 = jczsServiceFeignClient.page(pageIndex, PAGE_SIZE, null, tzBaseEnterpriseInfoDto);
Page<TzBaseEnterpriseInfoDto> resultPage = page1.getResult();
ResponseModel<Page<Map<String, String>>> page1 = jczsServiceFeignClient.page(pageIndex, PAGE_SIZE, null, map);
Page<Map<String, String>> resultPage = page1.getResult();
return resultPage.getRecords().stream()
.map(BaseDto::getSequenceNbr)
.map(item -> item.getOrDefault("sequenceNbr", ""))
.map(String::valueOf)
.collect(Collectors.toList());
}, executorService);
......@@ -800,12 +800,11 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
* 基础设置-企业信息列表数据导出
*
* @param ids
* @param tzBaseEnterpriseInfoDto
*/
@Override
public void enterpriseInformationExport(String uuid, String ids, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto) {
public void enterpriseInformationExport(String uuid, String ids, Map<String, String> map) {
ObjectMapper objectMapper = new ObjectMapper();
List<String> enterSeqs = getEnterSeqs(ids, tzBaseEnterpriseInfoDto);
List<String> enterSeqs = getEnterSeqs(ids, map);
List<Map<String, String>> enterInfoWithExport = tzBaseEnterpriseInfoMapper.getEnterInfoWithExport(enterSeqs);
List<BaseEnterpriseVo> exportData = JSON.parseArray(JSON.toJSONString(enterInfoWithExport), BaseEnterpriseVo.class);
exportData.forEach(item -> {
......@@ -824,6 +823,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
}
}
});
DictUtil.dictCode2DictName(exportData);
MultipartFile templateExcelFile = ExcelUtil.createTemplateExcelFile("企业信息列表数据", "企业信息列表列表", exportData, BaseEnterpriseVo.class, null, false);
String urlString = this.uploadExcelFile(templateExcelFile);
this.sendDownLoadExcelMsg(String.format(DOWNLOAD_TOPIC, RequestContext.getToken()), new JSONObject()
......@@ -844,7 +844,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
int totalPage = (int) Math.ceil((double) pageResult.getTotal() / PAGE_SIZE);
List<CompletableFuture<List<String>>> futures = new ArrayList<>();
List<String> idsCollected = pageResult.getRecords().stream()
.map(item -> item.getOrDefault("sequenceNbr", null))
.map(item -> isAdmin ? item.getOrDefault("uid", null) : item.getOrDefault("sequenceNbr", null))
.filter(Objects::nonNull)
.map(String::valueOf)
.collect(Collectors.toList());
......@@ -857,7 +857,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
tcmServiceFeignClient.page(String.valueOf(pageIndex), String.valueOf(PAGE_SIZE), null, map);
Page<Map<String, String>> resultPage = page1.getResult();
return resultPage.getRecords().stream()
.map(item -> item.getOrDefault("sequenceNbr", null))
.map(item -> isAdmin ? item.getOrDefault("uid", null) : item.getOrDefault("sequenceNbr", null))
.filter(Objects::nonNull)
.map(String::valueOf)
.collect(Collectors.toList());
......
package com.yeejoin.amos.boot.module.jg.biz.utils;
import cn.hutool.extra.spring.SpringUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
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.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -16,6 +22,7 @@ public class DictUtil {
/**
* 配合注解@DictCode2DictName(code="",type="")使用
* 将字段从dictCode转化为dictName
* 日期格式化,使用@JsonFormat注解
*
* @param data 需要转化的数据
*/
......@@ -43,6 +50,9 @@ public class DictUtil {
String type = annotation.type();
String typeHandler = annotation.typeHandler();
String name = "";
if ("null".equals(code)) {
return;
}
Object handler = SpringUtil.getBean(typeHandler);
......@@ -58,6 +68,73 @@ public class DictUtil {
} catch (IllegalAccessException | IllegalArgumentException e) {
log.error("字段赋值失败: {}, 类型: {}", field.getName(), data.getClass().getName(), e);
}
} else if (field.isAnnotationPresent(JsonFormat.class)) {
try {
Object value = field.get(data);
if (value == null) return;
JsonFormat jsonFormat = field.getAnnotation(JsonFormat.class);
String pattern = jsonFormat.pattern();
if (pattern == null || pattern.isEmpty()) return;
String formatted = null;
if (value instanceof Date) {
formatted = new SimpleDateFormat(pattern).format((Date) value);
} else if (value instanceof LocalDateTime) {
formatted = ((LocalDateTime) value).format(DateTimeFormatter.ofPattern(pattern));
} else if (value instanceof LocalDate) {
formatted = ((LocalDate) value).format(DateTimeFormatter.ofPattern(pattern));
} else if (value instanceof Long) { // 时间戳
Date date = new Date((Long) value);
formatted = new SimpleDateFormat(pattern).format(date);
} else if (value instanceof String) {
String str = (String) value;
LocalDateTime parsedDateTime = null;
str = str.trim().replaceAll("^[^\\d]+", "");
// 判断是否是长整型时间戳字符串
if (str.matches("^\\d{13,}$")) {
try {
long timestamp = Long.parseLong(str);
Date date = new Date(timestamp);
formatted = new SimpleDateFormat(pattern).format(date);
} catch (Exception e) {
throw e;
}
} else {
// 尝试常规格式解析
String[] parsePatterns = {
"yyyy-MM-dd HH:mm:ss",
"yyyy-MM-dd'T'HH:mm:ss",
"yyyy-MM-dd"
};
for (String parsePattern : parsePatterns) {
try {
DateTimeFormatter parser = DateTimeFormatter.ofPattern(parsePattern);
if (parsePattern.contains("HH")) {
parsedDateTime = LocalDateTime.parse(str, parser);
} else {
parsedDateTime = LocalDate.parse(str, parser).atStartOfDay();
}
break;
} catch (Exception ignore) {
}
}
if (parsedDateTime != null) {
formatted = parsedDateTime.format(DateTimeFormatter.ofPattern(pattern));
}
}
}
if (formatted != null) {
if (field.getType().equals(String.class)) {
field.set(data, formatted);
}
}
} catch (Exception e) {
log.error("日期字段: " + field.getName() + " 格式化失败: " + e.getMessage());
}
}
}
}
......
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