@@ -58,33 +58,33 @@ public class InstructionServiceImpl implements IInstructionService {
" \ n " ;
@Override
public String execute ( String command ) {
public List < String> execute ( String command ) {
if ( command = = null | | command . trim ( ) . isEmpty ( ) ) {
return " 请输入指令 " ;
return Collections . singletonList ( " 请输入指令 " ) ;
}
String input = command . trim ( ) ;
// 一级命令分流:京系(统计/订单)、录单/慢单、转链/礼金…
if ( input . startsWith ( " 京 " ) | | menuKeywords ( ) . contains ( input ) ) {
return handleJingFen ( input . replaceFirst ( " ^京 " , " " ) ) ;
return Collections . singletonList ( handleJingFen( input . replaceFirst ( " ^京 " , " " ) ) ) ;
}
// TF/H/生 生成类指令
if ( input . startsWith ( " TF " ) ) {
return handleTF ( input ) ;
return Collections . singletonList ( handleTF( input ) ) ;
}
if ( input . startsWith ( " H " ) ) {
return handleH ( input ) ;
return Collections . singletonList ( handleH( input ) ) ;
}
if ( input . startsWith ( " 生 " ) ) {
return handleSheng ( input ) ;
return Collections . singletonList ( handleSheng( input ) ) ;
}
if ( input . startsWith ( " 录单 " ) | | input . startsWith ( " 慢单 " ) | | input . startsWith ( " 慢搜 " ) | | input . startsWith ( " 慢查 " ) | | input . startsWith ( " 单 " ) ) {
return handleRecordLike ( input ) ;
return handleRecordLikeMulti ( input ) ;
}
if ( input . startsWith ( " 转链 " ) | | input . startsWith ( " 文案 " ) | | input . startsWith ( " 转 " ) ) {
return handleTransferLike ( input ) ;
return Collections . singletonList ( handleTransferLike( input ) ) ;
}
return helpText ( ) ;
return Collections . singletonList ( helpText( ) ) ;
}
private Set < String > menuKeywords ( ) {
@@ -124,18 +124,18 @@ public class InstructionServiceImpl implements IInstructionService {
}
}
private String handleRecordLike ( String input ) {
private List < String> handleRecordLikeMulti ( String input ) {
// 仅实现“慢搜/慢查 关键词”与“录单/慢单 日期范围”的只读输出,避免侵入写库
if ( input . startsWith ( " 慢搜 " ) | | input . startsWith ( " 慢查 " ) ) {
String kw = input . replaceFirst ( " ^慢搜|^慢查 " , " " ) . trim ( ) ;
if ( kw . isEmpty ( ) ) return " 请输入搜索关键词 " ;
if ( kw . isEmpty ( ) ) return Collections . singletonList ( " 请输入搜索关键词 " ) ;
List < JDOrder > list = jdOrderService . selectJDOrderList ( new JDOrder ( ) ) ;
if ( list = = null ) list = Collections . emptyList ( ) ;
String low = kw . toLowerCase ( Locale . ROOT ) ;
List < JDOrder > matched = list . stream ( ) . filter ( o - >
contains ( o . getRemark ( ) , low ) | | contains ( o . getOrderId ( ) , low ) | | contains ( o . getModelNumber ( ) , low ) | | contains ( o . getAddress ( ) , low ) | | contains ( o . getBuyer ( ) , low )
) . limit ( 50 ) . collect ( Collectors . toList ( ) ) ;
if ( matched . isEmpty ( ) ) return " 未找到匹配的订单 " ;
if ( matched . isEmpty ( ) ) return Collections . singletonList ( " 未找到匹配的订单 " ) ;
StringBuilder sb = new StringBuilder ( ) ;
int i = 0 ;
for ( JDOrder o : matched ) {
@@ -154,7 +154,7 @@ public class InstructionServiceImpl implements IInstructionService {
. append ( " \ n备注: " ) . append ( nvl ( o . getStatus ( ) ) )
. append ( " \ n━━━━━━━━━━━━ \ n " ) ;
}
return sb . toString ( ) ;
return Collections . singletonList ( sb. toString ( ) ) ;
}
if ( input . startsWith ( " 录单 " ) ) {
// 录单导出样式( tab)
@@ -168,7 +168,7 @@ public class InstructionServiceImpl implements IInstructionService {
List < JDOrder > list = jdOrderService . selectJDOrderList ( new JDOrder ( ) ) ;
if ( list = = null ) list = Collections . emptyList ( ) ;
List < JDOrder > filtered = list . stream ( ) . filter ( o - > o . getOrderTime ( ) ! = null & & ! o . getOrderTime ( ) . before ( start ) & & ! o . getOrderTime ( ) . after ( end ) ) . collect ( Collectors . toList ( ) ) ;
if ( filtered . isEmpty ( ) ) return " 今天没有订单。 " ;
if ( filtered . isEmpty ( ) ) return Collections . singletonList ( " 今天没有订单。 " ) ;
// 按 remark 排序
List < JDOrder > sorted = filtered . stream ( ) . sorted ( Comparator . comparing ( JDOrder : : getRemark , Comparator . nullsFirst ( String : : compareTo ) ) ) . collect ( Collectors . toList ( ) ) ;
StringBuilder sb = new StringBuilder ( ) ;
@@ -185,7 +185,7 @@ public class InstructionServiceImpl implements IInstructionService {
. append ( mapDistribution ( o . getDistributionMark ( ) ) ) . append ( '\t' )
. append ( nvl ( o . getStatus ( ) ) ) . append ( " \ n " ) ;
}
return sb . toString ( ) ;
return Collections . singletonList ( sb. toString ( ) ) ;
}
if ( input . startsWith ( " 慢单 " ) ) {
// 慢单:分销标记分组 -> 型号统计 + 详情
@@ -199,13 +199,12 @@ public class InstructionServiceImpl implements IInstructionService {
List < JDOrder > list = jdOrderService . selectJDOrderList ( new JDOrder ( ) ) ;
if ( list = = null ) list = Collections . emptyList ( ) ;
List < JDOrder > filtered = list . stream ( ) . filter ( o - > o . getOrderTime ( ) ! = null & & ! o . getOrderTime ( ) . before ( start ) & & ! o . getOrderTime ( ) . after ( end ) ) . collect ( Collectors . toList ( ) ) ;
if ( filtered . isEmpty ( ) ) return " 今天没有订单。 " ;
if ( filtered . isEmpty ( ) ) return Collections . singletonList ( " 今天没有订单。 " ) ;
Map < String , List < JDOrder > > byDM = filtered . stream ( )
. filter ( o - > o . getStatus ( ) = = null | | ! " 拍错退款 " . equals ( o . getStatus ( ) ) )
. collect ( Collectors . groupingBy ( JDOrder : : getDistributionMark ) ) ;
StringBuilder out = new StringBuilder ( ) ;
List < String > outputs = new ArrayList < > ( ) ;
List < Map . Entry < String , List < JDOrder > > > dmEntries = new ArrayList < > ( byDM . entrySet ( ) ) ;
dmEntries . sort ( Comparator . comparing ( en - > en . getKey ( ) = = null ? " " : en . getKey ( ) ) ) ;
for ( Map . Entry < String , List < JDOrder > > e : dmEntries ) {
@@ -238,17 +237,18 @@ public class InstructionServiceImpl implements IInstructionService {
. append ( " \ n地址: " ) . append ( o . getAddress ( ) ! = null ? o . getAddress ( ) : " 未提供 " )
. append ( " \ n物流链接: \ n " ) . append ( o . getLogisticsLink ( ) ! = null ? o . getLogisticsLink ( ) : " 无 " ) ;
}
out . append ( " 分销标记: " ) . append ( dm )
StringBuilder single = new StringBuilder ( ) ;
single . append ( " 分销标记: \ n ") . append ( dm )
. append ( summary )
. append ( detail ) . append ( " \ n " ) ;
outputs . add ( single . toString ( ) . trim ( ) ) ;
}
return out . toString ( ) . trim ( ) ;
return outputs . isEmpty ( ) ? Collections . singletonList ( " 无数据 " ) : outputs ;
}
if ( input . startsWith ( " 单 " ) ) {
return handleDanWriteDb ( input ) ;
return Collections . singletonList ( handleDanWriteDb( input ) ) ;
}
return helpText ( ) ;
return Collections . singletonList ( helpText( ) ) ;
}
// ===== TF/H/生 处理 =====