修复CusBaseAction中没有获取明细id

main
youHong.ai 2022-11-22 18:21:50 +08:00
parent 25db7d1f55
commit 2c0300f8d4
4 changed files with 15 additions and 12 deletions

View File

@ -192,7 +192,7 @@ public abstract class CusBaseAction implements Action {
if (null == propertyArr) { if (null == propertyArr) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 0.75)); Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 1.4));
for (Property property : propertyArr) { for (Property property : propertyArr) {
String fieldName = property.getName(); String fieldName = property.getName();
String value = property.getValue(); String value = property.getValue();
@ -209,7 +209,7 @@ public abstract class CusBaseAction implements Action {
*/ */
protected Map<String, List<Map<String, String>>> getDetailTableValue() { protected Map<String, List<Map<String, String>>> getDetailTableValue() {
DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable(); DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable();
Map<String, List<Map<String, String>>> detailDataList = new HashMap<>((int) Math.ceil(detailTableArr.length * 0.75)); Map<String, List<Map<String, String>>> detailDataList = new HashMap<>((int) Math.ceil(detailTableArr.length * 1.4));
for (DetailTable detailTable : detailTableArr) { for (DetailTable detailTable : detailTableArr) {
List<Map<String, String>> detailData = getDetailValue(detailTable); List<Map<String, String>> detailData = getDetailValue(detailTable);
detailDataList.put(detailTable.getId(), detailData); detailDataList.put(detailTable.getId(), detailData);
@ -242,7 +242,8 @@ public abstract class CusBaseAction implements Action {
List<Map<String, String>> detailData = new ArrayList<>(rowArr.length); List<Map<String, String>> detailData = new ArrayList<>(rowArr.length);
for (Row row : rowArr) { for (Row row : rowArr) {
Cell[] cellArr = row.getCell(); Cell[] cellArr = row.getCell();
Map<String, String> rowData = new HashMap<>((int) Math.ceil(cellArr.length * 0.75)); Map<String, String> rowData = new HashMap<>((int) Math.ceil(cellArr.length * (1 + 0.4)));
rowData.put("id",row.getId());
for (Cell cell : cellArr) { for (Cell cell : cellArr) {
String fieldName = cell.getName(); String fieldName = cell.getName();
String value = cell.getValue(); String value = cell.getValue();

View File

@ -71,7 +71,7 @@ public class SftpConnectUtil extends ChannelSftp {
this.port = port; this.port = port;
this.password = password; this.password = password;
this.sftpTimeOut = sftpTimeOut; this.sftpTimeOut = sftpTimeOut;
this.login(); // this.login();
} }
@ -81,7 +81,7 @@ public class SftpConnectUtil extends ChannelSftp {
* @author youHong.ai * @author youHong.ai
*/ */
private void login() { public ChannelSftp login() {
JSch jSch = new JSch(); JSch jSch = new JSch();
try { try {
@ -108,6 +108,7 @@ public class SftpConnectUtil extends ChannelSftp {
channel.connect(); channel.connect();
this.sftp = (ChannelSftp) channel; this.sftp = (ChannelSftp) channel;
this.success = true; this.success = true;
return sftp;
} catch (JSchException e) { } catch (JSchException e) {
throw new CustomerException("SFTP链接失败", e); throw new CustomerException("SFTP链接失败", e);
} }

View File

@ -32,10 +32,10 @@ public class FetchDataUtil {
public void downloadFile(SftpConnectUtil sftpConnectUtil,String fileName, public void downloadFile(ChannelSftp sftp,SftpConnectUtil sftpConnectUtil,
String targetFile){ String fileName, String targetFile){
try { try {
sftpConnectUtil.lcd("."); // sftpConnectUtil.lcd(".");
// Vector ls = sftpConnectUtil.ls("."); // Vector ls = sftpConnectUtil.ls(".");
// for (Object l : ls) { // for (Object l : ls) {
// System.out.println(l); // System.out.println(l);
@ -45,7 +45,7 @@ public class FetchDataUtil {
if (!file.exists()) { if (!file.exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
sftpConnectUtil.get(fileName,new FileOutputStream(targetFile)); sftp.get(fileName,new FileOutputStream(targetFile));
} catch (SftpException e) { } catch (SftpException e) {

View File

@ -3,6 +3,7 @@ package youhong.ai.pcn;
import aiyh.utils.fileUtil.sftp.SftpConnectUtil; import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
import baseTest.BaseTest; import baseTest.BaseTest;
import com.api.doc.detail.util.SFTPUtils; import com.api.doc.detail.util.SFTPUtils;
import com.jcraft.jsch.ChannelSftp;
import org.junit.Test; import org.junit.Test;
import weaver.general.GCONST; import weaver.general.GCONST;
import weaver.youhong.ai.pcn.hrorganization.sftp.FetchDataUtil; import weaver.youhong.ai.pcn.hrorganization.sftp.FetchDataUtil;
@ -25,9 +26,9 @@ public class TestOrganization extends BaseTest {
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.pem",null,"222.73.197.242", "/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.pem",null,"222.73.197.242",
null,1000 * 100 null,1000 * 100
); );
SFTPUtils sftpUtils = new SFTPUtils(); ChannelSftp login = sftpConnectUtil.login();
FetchDataUtil fetchDataUtil = new FetchDataUtil(); FetchDataUtil fetchDataUtil = new FetchDataUtil();
fetchDataUtil.downloadFile(sftpConnectUtil, fetchDataUtil.downloadFile(login, sftpConnectUtil,
"HRIS_DepartmentExport20200503", GCONST.getSysFilePath() + "HRIS_DepartmentExport20200503.csv"); "HRIS_PositionExport20221120", GCONST.getSysFilePath() + "HRIS_PositionExport20221120.csv");
} }
} }