1.修改往来单位导出为导出json文件

2.调整往来单位导出删除操作,删除导出日志时同步删除磁盘文件
master
MrZhai 3 years ago
parent f7442615dd
commit 16bd9d3810

@ -120,7 +120,8 @@ public class ThrCorpExportLogController {
@PostMapping("/udiwms/thrCorp/importLog/export")
public BaseResponse excelDownload(@RequestBody ThrCorpExportRequest thrCorpExportRequest) {
String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".xls";
//String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".xls";
String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".json";
File file = new File(fileName);
if (!file.exists()) {
try {
@ -138,7 +139,9 @@ public class ThrCorpExportLogController {
thrCorpExportLogEntity.setDlCount(0);
thrCorpExportLogEntity.setType(1);
thrCorpExportLogService.insertThrCorpExportLog(thrCorpExportLogEntity);
thrCorpsDlService.genExcel(genKey, thrCorpExportRequest);
//thrCorpsDlService.genExcel(genKey, thrCorpExportRequest);
//修改为导出json文件
thrCorpsDlService.genJsonFile(genKey, thrCorpExportRequest);
return ResultVOUtils.success("后台正在导出生成excel文件请稍后刷新查看!");
}

@ -18,4 +18,6 @@ public interface ThrCorpExportLogDao {
boolean updateThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity);
boolean deleteById(@Param("id") String id);
String selectFilePathById(@Param("id") String id);
}

@ -1,11 +1,11 @@
package com.glxp.api.admin.service.thrsys.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.dao.thrsys.ThrCorpExportLogDao;
import com.glxp.api.admin.entity.thrsys.ThrCorpExportLogEntity;
import com.glxp.api.admin.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.admin.req.basic.FilterUdiEpLogRequest;
import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest;
import com.glxp.api.admin.service.thrsys.ThrCorpExportLogService;
import org.springframework.stereotype.Service;
@ -54,6 +54,11 @@ public class ThrCorpExportLogServiceImpl implements ThrCorpExportLogService {
@Override
public boolean deleteById(String id) {
//删除日志同步删除文件
String filePath = thrCorpExportLogDao.selectFilePathById(id);
if (StrUtil.isNotBlank(filePath)) {
FileUtil.del(filePath);
}
return thrCorpExportLogDao.deleteById(id);
}
}

@ -1,10 +1,14 @@
package com.glxp.api.admin.thread;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.json.JSONUtil;
import com.glxp.api.admin.config.WebSocketServer;
import com.glxp.api.admin.constant.BasicProcessStatus;
import com.glxp.api.admin.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.admin.entity.thrsys.*;
import com.glxp.api.admin.entity.thrsys.ThrCorpEntity;
import com.glxp.api.admin.entity.thrsys.ThrCorpExportLogEntity;
import com.glxp.api.admin.entity.thrsys.ThrCorpImportDetailEntity;
import com.glxp.api.admin.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.admin.httpclient.ErpBasicClient;
import com.glxp.api.admin.req.basic.BasicUnitMaintainFilterRequest;
import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest;
@ -13,7 +17,10 @@ import com.glxp.api.admin.req.thrsys.ThrCorpExportRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.basic.ErpUnitsResponse;
import com.glxp.api.admin.service.basic.BasicThirdSysDetailService;
import com.glxp.api.admin.service.thrsys.*;
import com.glxp.api.admin.service.thrsys.ThrCorpExportLogService;
import com.glxp.api.admin.service.thrsys.ThrCorpImportDetailService;
import com.glxp.api.admin.service.thrsys.ThrCorpImportLogService;
import com.glxp.api.admin.service.thrsys.ThrCorpService;
import com.glxp.api.admin.util.Constant;
import com.glxp.api.admin.util.ExcelUtil;
import com.glxp.api.admin.util.RedisUtil;
@ -343,4 +350,52 @@ public class ThrCorpsDlService {
}
return excelData;
}
//导出生成json文件
@Async
public void genJsonFile(String genKey, ThrCorpExportRequest thrCorpExportRequest) {
ThrCorpExportLogEntity thrCorpExportLogEntity = thrCorpExportLogService.selectByGenKey(genKey);
List<List<String>> excelData = new ArrayList<>();
List<ThrCorpEntity> exportData = new ArrayList<>();
//选中导出
if (thrCorpExportRequest.getThrCorpEntities() != null && thrCorpExportRequest.getThrCorpEntities().size() > 0) {
List<ThrCorpEntity> corpEntities = thrCorpExportRequest.getThrCorpEntities();
exportData.addAll(corpEntities);
} else {//一键导出
//判断是否启用实时获取
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("corpUrl", thrCorpExportRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("往来单位接口地址未定义");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (!basicThirdSysDetailEntity.getEnabled()) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("第三方往来单位服务未启用");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (basicThirdSysDetailEntity.getFromType() == 0) {
//根据查询条件一键导出第三方系统往来单位
List<ThrCorpEntity> thrCorpEntities = exportCorps(thrCorpExportRequest);
exportData.addAll(thrCorpEntities);
} else {
//根据查询条件一键导出数据库往来单位
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<ThrCorpEntity> thrCorpEntities = thrCorpService.filterThrCorps(filterThrCorpRequest);
exportData.addAll(thrCorpEntities);
}
}
FileWriter writer = new FileWriter(thrCorpExportLogEntity.getFilePath());
writer.write(JSONUtil.toJsonStr(exportData));
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
}
}

@ -19,6 +19,9 @@
</where>
ORDER BY updateTime DESC
</select>
<select id="selectFilePathById" resultType="java.lang.String">
select filePath from thr_corp_export_log where id = #{id}
</select>
<insert id="insertThrCorpExportLog" keyProperty="id"

Loading…
Cancel
Save