|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
package com.glxp.api.admin.thread;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.file.FileWriter;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
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.info.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.*;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrProductsEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrProductsExportLogEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrProductsImportDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrProductsImportLogEntity;
|
|
|
|
|
import com.glxp.api.admin.httpclient.ErpBasicClient;
|
|
|
|
|
import com.glxp.api.admin.req.basic.FilterErpGoodsRequest;
|
|
|
|
|
import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest;
|
|
|
|
@ -422,6 +426,17 @@ public class ThrProductsDlService {
|
|
|
|
|
return excelData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ThrProductsEntity> genJsonData(String id, FilterThrProductsRequest filterThrProductsRequest) {
|
|
|
|
|
List<ThrProductsEntity> jsonData = new ArrayList<>();
|
|
|
|
|
if (id != null) {
|
|
|
|
|
ThrProductsEntity thrProductsEntity = thrProductsService.selectById(id);
|
|
|
|
|
jsonData.add(thrProductsEntity);
|
|
|
|
|
} else {
|
|
|
|
|
jsonData = thrProductsService.filterThrProductsRequest(filterThrProductsRequest);
|
|
|
|
|
}
|
|
|
|
|
return jsonData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<List<String>> getRows(List<ThrProductsEntity> thrProductsEntities) {
|
|
|
|
|
List<List<String>> excelData = new ArrayList<>();
|
|
|
|
|
for (ThrProductsEntity thrProductsEntity : thrProductsEntities) {
|
|
|
|
@ -437,4 +452,52 @@ public class ThrProductsDlService {
|
|
|
|
|
}
|
|
|
|
|
return excelData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导出json文件
|
|
|
|
|
@Async
|
|
|
|
|
public void genJsonFile(String genKey, ThrProductsExportRequest thrProductsExportRequest) {
|
|
|
|
|
|
|
|
|
|
ThrProductsExportLogEntity thrProductsExportLogEntity = thrProductsExportLogService.selectByGenKey(genKey);
|
|
|
|
|
|
|
|
|
|
List<ThrProductsEntity> exportData = new ArrayList<>();
|
|
|
|
|
//选中导出
|
|
|
|
|
if (thrProductsExportRequest.getThrProductsEntities() != null && thrProductsExportRequest.getThrProductsEntities().size() > 0) {
|
|
|
|
|
List<ThrProductsEntity> thrProductsEntities = thrProductsExportRequest.getThrProductsEntities();
|
|
|
|
|
exportData.addAll(thrProductsEntities);
|
|
|
|
|
} else {//一键导出
|
|
|
|
|
|
|
|
|
|
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", thrProductsExportRequest.getThirdSys());
|
|
|
|
|
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
|
|
|
|
|
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
|
|
|
|
|
thrProductsExportLogEntity.setRemark("产品信息接口未定义!");
|
|
|
|
|
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!basicThirdSysDetailEntity.getEnabled()) {
|
|
|
|
|
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
|
|
|
|
|
thrProductsExportLogEntity.setRemark("第三方产品信息服务未启用!");
|
|
|
|
|
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (basicThirdSysDetailEntity.getFromType() == 0) {
|
|
|
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsExportRequest, filterThrProductsRequest);
|
|
|
|
|
List<ThrProductsEntity> thrProductsEntities = exportThrProducts(filterThrProductsRequest);
|
|
|
|
|
exportData.addAll(thrProductsEntities);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
FilterThrProductsRequest filterThrInvProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsExportRequest, filterThrInvProductsRequest);
|
|
|
|
|
List<ThrProductsEntity> jsonData = genJsonData(null, filterThrInvProductsRequest);
|
|
|
|
|
exportData.addAll(jsonData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FileWriter writer = new FileWriter(thrProductsExportLogEntity.getFilePath());
|
|
|
|
|
writer.write(JSONUtil.toJsonStr(exportData));
|
|
|
|
|
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
|
|
|
|
|
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|