世界杯万博体育

所以Dean和他的同事们,包括另一位出色的程序员SanjayGhemawat一起找到了解决方案。4.StreamStreamAPI是Java8另一个大特点,并且我认为我们还真的不知道这对我们的编码方式会产生多大的改变。程序实现初步实现ItemUtil.javapackagezzz.study.utils;?/**?*Createdbyshuqinon17/11/10.?*/?importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;?importjava.util.HashMap;importjava.util.Map;importjava.util.Set;?importstaticzzz.study.utils.NewMapUtil.merge;?/**?*Createdbyshuqinon17/10/23.?*/publicclassItemUtil{??privatestaticLoggerlogger=LoggerFactory.getLogger(ItemUtil.class);??/**??*构建一个订单的所有商品级别的信息以及映射??*@parammultiItemInfoMapForOneOrder一个订单下多个商品的信息??*@return一个订单的所有商品级别的信息以及映射??*??*key是sID+order_no+item_id;item_id对应item.id,对应item_core.item_core_id??*/?publicstaticMap>buildFinalOrderItemMap(MapmultiItemInfoMapForOneOrder){??try{???returnmergeOrderItemMap(buildItemIndexMap(multiItemInfoMapForOneOrder));??}catch(Exceptionex){???logger.error("failedtobuildFinalOrderItemMapfor:"+multiItemInfoMapForOneOrder,ex);???returnnewHashMap<>();??}??}??/**??*构建一个订单的所有商品级别的信息以及映射??*@paramitemInfoMap商品级别的信息??*@return一个订单的所有商品的信息??*??*NOTE:itemInfoMap是对应一个订单的所有商品的信息的映射,不要传多个订单的信息进来,可能重复??*??*key=table:table_unique_id,value=map[table:field,value]??*??*eg.map[item:goods_type:1800888=0,item:num:1800888=8]??*???willbetransformedintomap[item:1800888=map[item:goods_type=0,item:num=8]]??*/?publicstaticMap>buildItemIndexMap(MapitemInfoMap){??Map>itemIndexMap=newHashMap<>();???itemInfoMap.forEach(????(key,value)->{?????String[]keyparts=key.split(":");??????//只考虑三段式tablename:field:id?????if(keyparts!=null&&keyparts.length==3){??????Stringtable=keyparts[0];??????Stringfield=keyparts[1];??????Stringindex=keyparts[2];???????StringindexKey=table+":"+index;??????StringfieldKey=table+":"+field;??????if(itemIndexMap.get(indexKey)==null){???????itemIndexMap.put(indexKey,newHashMap<>());??????}??????itemIndexMap.get(indexKey).put(fieldKey,String.valueOf(value));?????}????}??);???returnitemIndexMap;?}??/**??*聚合一个订单下的所有商品信息??*@paramitemIndexMap一个订单所有商品的信息映射??*@return一个订单下的所有商品信息??*??*key是sID+order_no+item_id;item_id对应item.id,item_core.item_core_id??*/?privatestaticMap>mergeOrderItemMap(Map>itemIndexMap){???if(itemIndexMap==null||itemIndexMap.isEmpty()){???returnnewHashMap<>();??}???//Map[oldItemId,newItemId]??Mapold2newItemIdMap=newHashMap<>();??Mapnew2oldItemIdMap=newHashMap<>();???Set>>entries=itemIndexMap.entrySet();??StringorderNo="";??StringsID="";??for(Map.Entry>entry:entries){???StringindexKey=entry.getKey();???Mapvalue=entry.getValue();????if(indexKey.startsWith("item:")){????old2newItemIdMap.put(indexKey,value.get("item:item_core_id"));????new2oldItemIdMap.put(value.get("item:item_core_id"),indexKey);????orderNo=value.get("item:order_no");????sID=value.get("item:s_id");???}??}???Map>newItemIndexMap=newHashMap<>();???for(Map.Entry>entry:entries){???StringindexKey=entry.getKey();???Mapvalue=entry.getValue();????if(indexKey.startsWith("item:")){????if(newItemIndexMap.get(indexKey)==null){?????newItemIndexMap.put(indexKey,newHashMap<>());????}????newItemIndexMap.get(indexKey).putAll(value);???}???elseif(indexKey.startsWith("item_core:")){????StringitemCoreId=indexKey.split(":")[1];????StringoldItemId=new2oldItemIdMap.get(itemCoreId);????if(newItemIndexMap.get(oldItemId)==null){?????newItemIndexMap.put(oldItemId,newHashMap<>());????}????newItemIndexMap.get(oldItemId).putAll(value);???}???elseif(indexKey.startsWith("item_price:")){????//item_price与item_id一对一关系????StringitemCoreId=itemIndexMap.get(indexKey).get("item_price:item_id");????StringoldItemId=new2oldItemIdMap.get(itemCoreId);????if(newItemIndexMap.get(oldItemId)==null){?????newItemIndexMap.put(oldItemId,newHashMap<>());????}????newItemIndexMap.get(oldItemId).putAll(value);???}???elseif(indexKey.startsWith("item_price_change_log:")){????//item_price_change_log与item_id多对一关系????StringitemCoreId=itemIndexMap.get(indexKey).get("item_price_change_log:item_id");????StringoldItemId=new2oldItemIdMap.get(itemCoreId);????if(newItemIndexMap.get(oldItemId)==null){?????newItemIndexMap.put(oldItemId,newHashMap<>());????}????MapsrcMap=newItemIndexMap.get(oldItemId);????newItemIndexMap.get(oldItemId).putAll(merge(srcMap,value));???}???}???returnbuildFinalOrderItemMap(newItemIndexMap,old2newItemIdMap,orderNo,sID);??}???/**??*构建最终的订单商品信息??*@paramitemIndexMap商品信息??*@paramold2newItemIdMap新老itemId映射??*@paramorderNo订单号??*@paramsID店铺号??*@return订单商品扩展信息??*/?privatestaticMap>buildFinalOrderItemMap(Map>itemIndexMap,????????????????????????????????????Mapold2newItemIdMap,????????????????????????????????????StringorderNo,StringsID){??Map>finalResult=newHashMap<>();???Set>>entries=itemIndexMap.entrySet();???for(Map.Entry>entry:entries){???StringindexKey=entry.getKey();???Mapvalue=entry.getValue();????StringitemId=indexKey.split(":")[1];????StringitemKey=sID+"_"+orderNo+"_"+itemId;???finalResult.put(itemKey,value);??}??returnfinalResult;?}}NewMapUtil.javapackagezzz.study.utils;?importjava.util.ArrayList;importjava.util.HashMap;importjava.util.List;importjava.util.Map;?/**?*Createdbyshuqinon17/11/10.?*/publicclassNewMapUtil{??/**??*将map的值转为字符串类型??*/?publicstaticMaptransMap(Mapmap){??if(map==null){returnnull;}??Mapresult=newHashMap<>();??map.forEach(????(k,v)->result.put(k,v!=null?v.toString():null)??);??returnresult;?}??/**??*将两个Map里相同key的值合并为列表??*??*eg.src=["id":1,"detail":"haha111","extra":"extra111"],??*???dest=["id":2,"detail":"haha222","another":"another222"]??*merge之后返回["id":[1,2],"detail":["haha111","haha222"],"extra":"extra111","another":"another222"]??`??*/?publicstaticMapmerge(Mapsrc,Mapdest){??if(src==null||src.size()==0){returndest;}??if(dest==null||dest.size()==0){returnsrc;}???Mapresult=newHashMap<>();??src.forEach(????(key,value)->{?????ObjectvalueDesc=dest.get(key);?????if(valueDesc!=null){??????result.put(key,mergeToList(value,valueDesc));?????}?????else{??????result.put(key,value);?????}????}??);??dest.forEach(????(key,value)->{?????if(result.get(key)==null){??????result.put(key,value);?????}????}??);??returnresult;??}???publicstaticListmergeToList(Objectsrc,Object...args){??ListvalList=newArrayList();??add(valList,src);??for(Objectarg:args){???add(valList,arg);??}??returnvalList;?}??publicstaticListadd(ListvalList,Objectsrc){??if(src==null){returnvalList;}??if(srcinstanceofList){???valList.addAll((List)src);??}??else{???valList.add(src);??}??returnvalList;?}?}代码重构可以看到,初步实现虽然实现了功能,可是代码比较乱,尤其是mergeOrderItemMap方法,混杂了业务表的逻辑,理解和扩展起来比较麻烦。甚至是lambda所代表的函数式接口:3.针对Lambda表达式设计我认为lambda表达式有点像泛型——和泛型一起,我们经常使用它们(例如,添加类型信息到List),但最好我们可以设计一种方法或一个具有泛型类型(例如Person)的类。

教学科研service
教学质量/ teaching-quality
北关校区召开高三“二模”质量分析会
发布时间:2018-11-27 17:21:27     作者:    来源:
  

 

1126日,北关校区召开了高考“二模”质量分析会。副校长屈琦、屈文宏和高三全体教师参加会议。 

 

会上,副校长屈文宏详细分析比较了“二模”考试成绩统计数据,并对下一阶段备考提出了要求,全体教师要同心同德、和衷共济,坚持立足考纲、夯实基础、突出重点、提高效率的思路,统筹兼顾阶段备考工作和学科备考任务;坚定信念,扎实措施,明确思路,不断优化复习策略,准确把握考试方向;重视培优扶差工作的实效性和考生应考心态的调整,发扬刻苦勤奋的优良精神,奋力冲刺2019年高考。(图文/董乐阳) 

 

版权所有 万博最新2018网址 陕ICP备11011081号 站长信箱lf2007818@163.com
万博最新2018网址欢迎光临本站,您是第 访问者!网站建设-艺源视网
地址:铜川市新区朝阳路10号 电话:0919—3589821 管理登录