修改搜索功能

This commit is contained in:
wuweihua
2026-09-17 17:58:00 +08:00
parent 5dcea947a7
commit 63988b798e
14 changed files with 353 additions and 12 deletions
@@ -18,10 +18,14 @@ public class PrcOrderBill extends BaseEntity
private String billId;
private String billKey;
private String orderNo;
/** 批量查询:多个订单号精确匹配(仅查询用,非表字段) */
private List<String> orderNos;
private String trackingNo;
private Long customerId;
private String customerCode;
private String customerName;
/** 批量查询:多个客户代码精确匹配(仅查询用,非表字段) */
private List<String> customerCodes;
private Integer pieces;
private BigDecimal actualWeight;
private BigDecimal volume;
@@ -38,6 +42,8 @@ public class PrcOrderBill extends BaseEntity
private String orderRemark;
private String productCode;
private String productName;
/** 批量查询:多个产品代码精确匹配(仅查询用,非表字段) */
private List<String> productCodes;
private String countryCode;
private String countryName;
private BigDecimal weight;
@@ -15,6 +15,9 @@ public interface PrcOrderBillMapper
public List<PrcOrderBill> selectPrcOrderBillList(PrcOrderBill bill);
/** 订单号下拉搜索:按关键词模糊匹配,返回去重后的订单号(按最近创建排序,限量返回) */
public List<String> selectOrderNoOptions(@Param("keyword") String keyword, @Param("limit") int limit);
/** 应收账单生成读取指定客户截止日期前的未出账订单计费快照。 */
public List<PrcOrderBill> selectPrcOrderBillByCustomerPeriod(@Param("customerId") Long customerId,
@Param("customerCode") String customerCode, @Param("cutoffDate") Date cutoffDate,
@@ -12,6 +12,9 @@ public interface IPrcOrderBillService
List<PrcOrderBill> selectBillList(PrcOrderBill query);
/** 订单号下拉搜索选项(模糊匹配,去重限量) */
List<String> listOrderNoOptions(String keyword);
TmsPriceQuoteResult getBill(String billId);
TmsPriceQuoteResult getBillByOrderNo(String orderNo);
@@ -4,9 +4,12 @@ import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -88,9 +91,41 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
@Override
public List<PrcOrderBill> selectBillList(PrcOrderBill query)
{
query.setOrderNos(normalizeCodeList(query.getOrderNos()));
query.setCustomerCodes(normalizeCodeList(query.getCustomerCodes()));
query.setProductCodes(normalizeCodeList(query.getProductCodes()));
return orderBillMapper.selectPrcOrderBillList(query);
}
@Override
public List<String> listOrderNoOptions(String keyword)
{
if (StringUtils.isBlank(keyword))
{
return new ArrayList<>();
}
return orderBillMapper.selectOrderNoOptions(keyword.trim(), 20);
}
/**
* 批量编码归一化:逐个 trim、拆开误传的逗号/分号/空白分隔串、去空去重
*/
private List<String> normalizeCodeList(List<String> codes)
{
if (codes == null || codes.isEmpty())
{
return null;
}
List<String> cleaned = codes.stream()
.filter(StringUtils::isNotBlank)
.map(s -> s.split("[,,;;\\s]+"))
.flatMap(Arrays::stream)
.map(String::trim)
.filter(StringUtils::isNotBlank)
.collect(Collectors.collectingAndThen(Collectors.toList(), list -> new ArrayList<>(new LinkedHashSet<>(list))));
return cleaned.isEmpty() ? null : cleaned;
}
@Override
public TmsPriceQuoteResult getBill(String billId)
{
@@ -87,24 +87,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where bill_id = #{billId}
</select>
<select id="selectOrderNoOptions" resultType="String">
select order_no
from prc_order_bill
<where>
<if test="keyword != null and keyword != ''">
order_no like concat('%', #{keyword}, '%')
</if>
</where>
group by order_no
order by max(create_time) desc
limit #{limit}
</select>
<select id="selectPrcOrderBillList" parameterType="PrcOrderBill" resultMap="PrcOrderBillResult">
<include refid="selectPrcOrderBillVo"/>
<where>
<if test="orderNo != null and orderNo != ''">
AND order_no like concat('%', #{orderNo}, '%')
</if>
<if test="orderNos != null and orderNos.size() > 0">
AND order_no IN
<foreach collection="orderNos" item="ono" open="(" separator="," close=")">
#{ono}
</foreach>
</if>
<if test="trackingNo != null and trackingNo != ''">
AND tracking_no like concat('%', #{trackingNo}, '%')
</if>
<if test="customerCode != null and customerCode != ''">
AND customer_code like concat('%', #{customerCode}, '%')
</if>
<if test="customerCodes != null and customerCodes.size() > 0">
AND customer_code IN
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
#{ccode}
</foreach>
</if>
<if test="customerName != null and customerName != ''">
AND customer_name like concat('%', #{customerName}, '%')
</if>
<if test="productCode != null and productCode != ''">
AND product_code like concat('%', #{productCode}, '%')
</if>
<if test="productCodes != null and productCodes.size() > 0">
AND product_code IN
<foreach collection="productCodes" item="pcode" open="(" separator="," close=")">
#{pcode}
</foreach>
</if>
<if test="countryCode != null and countryCode != ''">
AND country_code = #{countryCode}
</if>