侃侃无极
给一个大概思路吧。java实现。可以稍微参考下。packagecom.ui;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.HashMap;importjava.util.HashSet;importjava.util.Iterator;importjava.util.List;importjava.util.Map;importjava.util.Set;publicclassOrderStatusService{/***映射关系列表*/publicstaticListmapperList=newArrayList();static{/***初始化判断项、订单动作到状态的映射,这里只为演示,实际中映射关系最好保存在配置文件中或者数据库中,一般在应用启动的时候,从配置文件或者数据库加载,保存一份即可。**/OrderStatusMapperm1=newOrderStatusMapper();m1.addJudgementItems(1,2,4,6)//先吃后付and自动接单and有打印机and打印成功.addAction2statusItem(1,6)//下单动作:进行中.addAction2statusItem(7,4);//结账动作:已完成OrderStatusMapperm2=newOrderStatusMapper();m2.addJudgementItems(3,5).addAction2statusItem(2,1).addAction2statusItem(4,3);mapperList.add(m1);mapperList.add(m2);}/***是否是相等的set*@paramsource*@paramdest*@return*/publicbooleanisEqualSet(Setsource,Setdest){if(null==source||null==dest){returnfalse;}if(source.size()!=dest.size()){returnfalse;}for(Iteratorit=source.iterator();it.hasNext();){if(!dest.contains(it.next())){returnfalse;}}returntrue;}publicstaticvoidmain(String[]args){Orderorder=newOrder();order.setOrderAction(1);//下单order.setJudgementItems(newHashSet(Arrays.asList(1,2,4,6)));//先吃后付and自动接单and有打印机and打印成功//获取订单下一个状态System.out.println(newOrderStatusService().getNextOrderStatus(order));//结果为6(进行中)}/***获取下一个订单状态*@paramcurOrder*@return*/publicIntegergetNextOrderStatus(OrdercurOrder){for(OrderStatusMappermapper:mapperList){if(isEqualSet(curOrder.getJudgementItems(),mapper.getJudgementItems())&&null!=curOrder.getOrderAction()){returnmapper.getAction2statusMap().get(curOrder.getOrderAction());}}returnnull;}}/***订单类型,订单动作到状态的映射。**/classOrderStatusMapper{/***判断项*/privateSetjudgementItems=newHashSet();/***订单动作到状态关系*/privateMapaction2statusMap=newHashMap();/***下一个订单状态*/privateIntegernextStatus;publicSetgetJudgementItems(){returnjudgementItems;}publicOrderStatusMapperaddJudgementItems(Integer...items){if(null==items||items.length