Compare commits

...

4 Commits

  1. 24
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java
  2. 10
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java
  3. 68
      src/main/java/com/xujie/sys/modules/pms/service/Impl/EamObjectServiceImpl.java
  4. 35
      src/main/java/com/xujie/sys/modules/pms/service/Impl/EamProjectServiceImpl.java
  5. 2
      src/main/resources/mapper/ecss/CoDelMapper.xml

24
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java

@ -458,6 +458,13 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
continue;
}
// 获取pn列索引
Integer pnIdx = columnMap.get("PN");
if (pnIdx == null) {
log.warn("Sheet [{}] 中未找到 'PN' 列,跳过该Sheet", sheetName);
continue;
}
// Cargo Ready Date 列存在说明要处理这个 sheet验证其他必填列
String[] requiredColumns = {
"PO#", // 必填
@ -543,13 +550,12 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
continue;
}
// 检查Cargo Ready Date列如果没有值则跳过该行
if (row.getCell(cargoReadyDateIdx) == null
|| row.getCell(cargoReadyDateIdx).getCellType() == CellType.BLANK
|| row.getCell(cargoReadyDateIdx).getCellType() == CellType.ERROR) {
log.debug("第{}行的Cargo Ready Date列为空,跳过该行", j+1);
continue;
}
// 检查PN列如果没有值则跳过该行
if (row.getCell(pnIdx) == null || row.getCell(pnIdx).getCellType() == CellType.BLANK
|| row.getCell(pnIdx).getCellType() == CellType.ERROR) {
log.debug("第{}行的PN列为空,跳过该行", j+1);
continue;
}
// 跳过内销数据如果"内外销方式"列存在
Integer saleTypeIdx = columnMap.get("内外销方式");
@ -566,7 +572,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
continue; // 跳过这一行继续处理下一行
}
Integer pnIdx = columnMap.get("PN");
//Integer pnIdx = columnMap.get("PN");
if (row.getCell(pnIdx) == null) {
currentSheetError.addErrorDetail("第" + (j+1) + "行的 [PN] 列不能为空");
hasRowError = true;
@ -624,7 +630,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
String formatted = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
readDate = DateUtils.getDateByParten(formatted, "yyyy-MM-dd");
} catch (Exception e) {
currentSheetError.addErrorDetail("第" + (j+1) + "行的 [Cargo Ready Date] 列格式有误: " + e.getMessage());
currentSheetError.addErrorDetail("第" + (j+1) + "行的 [Cargo Ready Date] 列格式有误");
hasRowError = true;
continue;
}

10
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java

@ -300,10 +300,10 @@ public class CoDelServiceImpl implements CoDelService {
if (checkHeader.isEmpty()) {
throw new RuntimeException("不存在该发货通知单,请刷新界面");
}
// 调用Mapper方法执行批量更新
int updatedRows = coDelMapper.fixTtlAmount(data);
if (updatedRows == 0) {
throw new RuntimeException("没有需要修正的明细数据");
}
@ -4206,7 +4206,9 @@ public class CoDelServiceImpl implements CoDelService {
}
Object detailRollsObj = detail.get("detailRolls");
if (detailRollsObj instanceof BigDecimal) {
if (detailRollsObj == null || "".equals(detailRollsObj)) {
palletDetailData.setRolls(BigDecimal.valueOf(0));
} else if (detailRollsObj instanceof BigDecimal) {
palletDetailData.setRolls((BigDecimal) detailRollsObj);
} else if (detailRollsObj instanceof Integer) {
palletDetailData.setRolls(BigDecimal.valueOf((Integer) detailRollsObj));
@ -4214,7 +4216,7 @@ public class CoDelServiceImpl implements CoDelService {
palletDetailData.setRolls(BigDecimal.valueOf((Double) detailRollsObj));
} else if (detailRollsObj instanceof String) {
palletDetailData.setRolls(new BigDecimal((String) detailRollsObj));
} else if (detailRollsObj != null) {
} else {
palletDetailData.setRolls(BigDecimal.valueOf(((Number) detailRollsObj).doubleValue()));
}

68
src/main/java/com/xujie/sys/modules/pms/service/Impl/EamObjectServiceImpl.java

@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -264,42 +265,57 @@ public class EamObjectServiceImpl implements EamObjectService {
}
@Override
public void downLoadObjectFile(Integer id, HttpServletResponse response) throws UnsupportedEncodingException {
//处理路径和名称
public void downLoadObjectFile(Integer id, HttpServletResponse response) {
List<SysOssEntity> getFileData = eamObjectMapper.getFileData(id);
if (getFileData.isEmpty()) {
if (getFileData == null || getFileData.isEmpty()) {
throw new RuntimeException("该文件不存在,请刷新列表");
}
File file = new File(getFileData.get(0).getUrl());
//读取缓存1kb
byte[] buffer = new byte[1024];
FileInputStream fis = null;
SysOssEntity fileEntity = getFileData.get(0);
File file = new File(fileEntity.getUrl());
if (!file.exists()) {
throw new RuntimeException("文件不存在");
}
response.setContentType("application/octet-stream");
response.setCharacterEncoding("UTF-8");
BufferedInputStream bis = null;
//FileOutputStream fos = null;
//BufferedOutputStream bos = null;
response.setContentType("application/force-download;charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename=" + new String(getFileData.get(0).getFileName().getBytes("gbk"), "iso8859-1"));
ServletOutputStream os = null;
try {
//读取文件
fis = new FileInputStream(file);
//加缓存
bis = new BufferedInputStream(fis);
//开始读取
int i = bis.read(buffer);
//设置输出流
ServletOutputStream os = response.getOutputStream();
//开始循环读取
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
// Java 8 安全写法
String fileName = URLEncoder.encode(fileEntity.getFileName(), "UTF-8")
.replaceAll("\\+", "%20");
response.setHeader(
"Content-Disposition",
"attachment; filename*=UTF-8''" + fileName
);
bis = new BufferedInputStream(new FileInputStream(file));
os = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = bis.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
fis.close();
//fos.close();
os.flush();
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
// 这里千万不要再动 response
throw new RuntimeException("文件下载失败", e);
} finally {
try {
if (bis != null) bis.close();
if (os != null) os.close();
} catch (IOException ignored) {
}
}
}
@Override
public void downLoadObjectFile2(Integer id,String orderRef3, HttpServletResponse response) throws UnsupportedEncodingException {
//处理路径和名称

35
src/main/java/com/xujie/sys/modules/pms/service/Impl/EamProjectServiceImpl.java

@ -44,6 +44,7 @@ import javax.mail.internet.MimeMessage;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.sql.CallableStatement;
import java.sql.Connection;
@ -74,6 +75,9 @@ public class EamProjectServiceImpl implements EamProjectService {
@Value("${sys-file.file-path}")
private String filePath;
@Value("${spring.datasource.druid.url}")
private String datasourceUrl;
@Autowired
private EamProjectMapper EamProjectMapper;
@ -1034,6 +1038,37 @@ public class EamProjectServiceImpl implements EamProjectService {
// 创建 StringBuilder 对象
StringBuilder s = new StringBuilder();
s.append("<ol>");
// 获取服务器IP地址
String serverIp = "";
try {
serverIp = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
serverIp = "无法获取";
logger.error("获取服务器IP失败: " + e.getMessage(), e);
}
// 从数据库URL中解析数据库名称
String databaseName = "";
try {
if (datasourceUrl != null && datasourceUrl.contains("databaseName=")) {
databaseName = datasourceUrl.substring(datasourceUrl.indexOf("databaseName=") + "databaseName=".length());
// 如果URL后面还有其他参数需要截取
if (databaseName.contains(";")) {
databaseName = databaseName.substring(0, databaseName.indexOf(";"));
}
} else {
databaseName = "无法获取";
}
} catch (Exception e) {
databaseName = "无法获取";
logger.error("解析数据库名称失败: " + e.getMessage(), e);
}
// 添加服务器信息和数据库信息
s.append("<p style='margin: 10px 0; font-weight: bold;'>服务器IP地址: <span style='color: #17B3A3;'>").append(serverIp).append("</span></p>");
s.append("<p style='margin: 10px 0; font-weight: bold;'>数据库名称: <span style='color: #17B3A3;'>").append(databaseName).append("</span></p>");
s.append("<br/>");
// 邮件内容模板
s.append("<table style='border-collapse: collapse; width: 100%;'>");
s.append("<tr style='background-color: #f2f2f2;'>");

2
src/main/resources/mapper/ecss/CoDelMapper.xml

@ -881,7 +881,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no
</select>
<select id="exportEcssCoDelNotifyDetail" resultType="java.util.Map">
select a.customerPO,a.part_no,a.part_description,a.currency,
select a.customerPO,a.part_no,a.part_description,LEFT(a.currency, 3) as currency,
CONVERT(DECIMAL(20, 0), a.qty) as qty,CONVERT(DECIMAL(20, 6), a.tp) as unitPrice,b.hsCode,
a.upc,a.so,a.ttl_amount,a.pn,h.hsCodeDesc,h.hsCodeDescEn,a.salesOrder
from ecss_CoDelNotifydetail a

Loading…
Cancel
Save