🐛 修复应收账单收货时间范围导出类型异常
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.bms.ar.mapper;
|
package com.bms.ar.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import com.bms.ar.domain.ArBillDetail;
|
import com.bms.ar.domain.ArBillDetail;
|
||||||
@@ -19,6 +20,8 @@ public interface ArBillDetailMapper {
|
|||||||
List<ArBillDetail> selectExportPage(@Param("arBillId") Long arBillId,
|
List<ArBillDetail> selectExportPage(@Param("arBillId") Long arBillId,
|
||||||
@Param("lastDetailNo") Integer lastDetailNo, @Param("pageSize") Integer pageSize);
|
@Param("lastDetailNo") Integer lastDetailNo, @Param("pageSize") Integer pageSize);
|
||||||
|
|
||||||
|
Map<String, Object> selectReceiveTimeRangeByBillId(@Param("arBillId") Long arBillId);
|
||||||
|
|
||||||
int insert(ArBillDetail detail);
|
int insert(ArBillDetail detail);
|
||||||
|
|
||||||
int insertBatch(List<ArBillDetail> details);
|
int insertBatch(List<ArBillDetail> details);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -1319,6 +1321,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Integer, String> templateRows = extractTemplateRows(templateXml.substring(sheetDataOpenEnd + 1, sheetDataEnd));
|
Map<Integer, String> templateRows = extractTemplateRows(templateXml.substring(sheetDataOpenEnd + 1, sheetDataEnd));
|
||||||
|
Map<String, Object> receiveTimeRange = detailMapper.selectReceiveTimeRangeByBillId(bill.getArBillId());
|
||||||
String prefix = adjustExportColumnWidths(
|
String prefix = adjustExportColumnWidths(
|
||||||
removeSheetDimension(templateXml.substring(0, sheetDataOpenEnd + 1)));
|
removeSheetDimension(templateXml.substring(0, sheetDataOpenEnd + 1)));
|
||||||
writeUtf8(output, prefix);
|
writeUtf8(output, prefix);
|
||||||
@@ -1329,7 +1332,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
writeUtf8(output, templateRows.get(2));
|
writeUtf8(output, templateRows.get(2));
|
||||||
String customerRow = replaceCellXml(templateRows.get(3), "C3", bill.getCustomerName(), false);
|
String customerRow = replaceCellXml(templateRows.get(3), "C3", bill.getCustomerName(), false);
|
||||||
// 账单所属期区域为 O3:T3 合并单元格,必须写入左上角 O3 才能显示。
|
// 账单所属期区域为 O3:T3 合并单元格,必须写入左上角 O3 才能显示。
|
||||||
customerRow = replaceCellXml(customerRow, "O3", exportPeriod(bill), false);
|
customerRow = replaceCellXml(customerRow, "O3", exportReceiveTimeRange(receiveTimeRange), false);
|
||||||
writeUtf8(output, customerRow);
|
writeUtf8(output, customerRow);
|
||||||
writeUtf8(output, templateRows.get(4));
|
writeUtf8(output, templateRows.get(4));
|
||||||
|
|
||||||
@@ -1731,17 +1734,32 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
return StringUtils.isEmpty(detail.getRemark()) ? detail.getGoodsDescription() : detail.getRemark();
|
return StringUtils.isEmpty(detail.getRemark()) ? detail.getGoodsDescription() : detail.getRemark();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String exportPeriod(ArBill bill) {
|
private String exportReceiveTimeRange(Map<String, Object> receiveTimeRange) {
|
||||||
Date start = bill.getBillPeriodStart();
|
if (receiveTimeRange == null) {
|
||||||
Date end = bill.getBillPeriodEnd();
|
return "";
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
if (start != null && end != null) {
|
|
||||||
return format.format(start) + " 至 " + format.format(end);
|
|
||||||
}
|
}
|
||||||
if (start != null) {
|
String start = formatReceiveDate(receiveTimeRange.get("minReceiveTime"));
|
||||||
return format.format(start) + " 起";
|
String end = formatReceiveDate(receiveTimeRange.get("maxReceiveTime"));
|
||||||
|
return StringUtils.isEmpty(start) || StringUtils.isEmpty(end) ? "" : start + " 至 " + end;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatReceiveDate(Object value) {
|
||||||
|
if (value instanceof LocalDateTime) {
|
||||||
|
return ((LocalDateTime) value).toLocalDate().toString();
|
||||||
}
|
}
|
||||||
return end == null ? "" : "截至 " + format.format(end);
|
if (value instanceof LocalDate) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
if (value instanceof java.sql.Date) {
|
||||||
|
return ((java.sql.Date) value).toLocalDate().toString();
|
||||||
|
}
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd").format((Date) value);
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("不支持的收货时间类型: " + value.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal exportUnitPrice(ArBillDetail detail) {
|
private BigDecimal exportUnitPrice(ArBillDetail detail) {
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
limit #{pageSize}
|
limit #{pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectReceiveTimeRangeByBillId" resultType="map">
|
||||||
|
select min(receive_time) as minReceiveTime, max(receive_time) as maxReceiveTime
|
||||||
|
from ar_bill_detail
|
||||||
|
where ar_bill_id = #{arBillId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insert" parameterType="ArBillDetail" useGeneratedKeys="true" keyProperty="detailId">
|
<insert id="insert" parameterType="ArBillDetail" useGeneratedKeys="true" keyProperty="detailId">
|
||||||
insert into ar_bill_detail (ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
|
insert into ar_bill_detail (ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
|
||||||
product_code,
|
product_code,
|
||||||
|
|||||||
Reference in New Issue
Block a user