* @description: 根据warehouseCode二层分级展示订单信息
* @param orderId
* @return
* @author:wangchong
* @createTime:2015年7月12日 下午4:54:23
*/
public static Map<String,List<OrderDetail>> queryOrderDetailsByOrderIdAndWarehouse(Object orderId)
{
OrderService orderService = (OrderService)SpringContext.getBean("orderService");
long id = NumberUtils.parseLong(orderId != null ? orderId.toString() : "");
List<OrderDetail> orderDetails = orderService.queryOrderDetailsByOrderId(id);
Map<String, List<OrderDetail>> differOrderDetail = new HashMap<String, List<OrderDetail>>();
for(OrderDetail orderDetail : orderDetails)
{
List<OrderDetail> details = null;
if(differOrderDetail.get(orderDetail.getWarehouseCode()) == null)
{
details = new ArrayList<OrderDetail>();
}
else
{
details = differOrderDetail.get(orderDetail.getWarehouseCode());
}
details.add(orderDetail);
differOrderDetail.put(orderDetail.getWarehouseCode(), details);
}
return differOrderDetail;
}
2={
共青码头={
id=224,
phone=13764872682,
fax=13764872680,
address=上港11区,
name=共青码头,
startTime=8:00,
endTime=17:00,
resourceMapList=[
{spec=螺纹钢, breed=螺纹钢, weightWayName=理重, score=33, breedId=5102, weightWay=0, qty=33.0, material=螺纹钢, averageQty=33.0, serialNo=333.0, onboardItems=32, resourceId=16463081, breedAlias=, onboardPrice=2000.0, brand=鞍钢,cityId=0101,city=上海,warehouse=共青码头,supplierName=充值测试专用,supplierId=1872,supplierPhone=021-88888888,memberId=210288,memberName=上海钢银电子商务股份有限公司}
],
code=
},
goodsMemberId=2,
name=天津钢银电子商务有限公司,
shortName=天津钢银,
我的钢铁网(兴晟二号)库={
id=48,
phone=13764872682,
fax=13764872680,
address=上海市宝山区园丰路,
name=我的钢铁网(兴晟二号)库,
startTime=8:00,
endTime=17:00,
resourceMapList=[
{spec=1.0*1250*2500, breed=冷轧盒板, weightWayName=理重, score=11, breedId=5412, weightWay=0, qty=11.0, material=DC01, averageQty=11.0, serialNo=111, onboardItems=11, resourceId=16463080, breedAlias=冷轧盒板, onboardPrice=2222.0, brand=鞍钢,cityId=0101,city=上海,warehouse=共青码头,supplierName=充值测试专用,supplierId=1872,supplierPhone=021-88888888,memberId=210288,memberName=上海钢银电子商务股份有限公司}
],
code=25
}
},
1={
共青码头={
id=224,
phone=13764872682,
fax=13764872680,
address=上港11区,
name=共青码头,
startTime=8:00,
endTime=17:00,
resourceMapList=[
{spec=1, breed=盘螺, weightWayName=理重, score=11, breedId=5101, weightWay=0, qty=11.0, material=1, averageQty=11.0, serialNo=11, onboardItems=10, resourceId=16463079, breedAlias=, onboardPrice=1500.0, brand=1,cityId=0101,city=上海,warehouse=共青码头,supplierName=充值测试专用,supplierId=1872,supplierPhone=021-88888888,memberId=210288,memberName=上海钢银电子商务股份有限公司},
{spec=12*10*C, breed=出厂平板, weightWayName=理重, score=99, breedId=5207, weightWay=0, qty=99.0, material=SPCD, averageQty=99.0, serialNo=, onboardItems=1, resourceId=16463077, breedAlias=, onboardPrice=3000.0, brand=鄂钢,cityId=0101,city=上海,warehouse=共青码头,supplierName=充值测试专用,supplierId=1872,supplierPhone=021-88888888,memberId=210288,memberName=上海钢银电子商务股份有限公司}
],
code=
},
goodsMemberId=1,
name=上海钢银电子商务股份有限公司,
shortName=上海钢银
}
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/searchCartResource", produces = { "text/plain;charset=GBK" })
@ResponseBody
public String searchCartResource(HttpServletRequest request, HttpServletResponse response)
{
Map<Long, Object> map = new HashMap<Long, Object>();
Map<String, Object> itemMap = new HashMap<String,Object>();
String cartResourceInfo = "";
List<String> resourceIdList = null;
String uid = ServletUtils.getCookieValue(request, "_login_uid");
String cookieKey = "supermarket_cart_" + uid;
String cartResources = VelocityTool.unEscape(VelocityTool.unEscape(ServletUtils.getCookieValue(request, cookieKey)));
if (StringUtils.notTrimEmpty(cartResources))
{
resourceIdList = new ArrayList<String>();
String[] cartResource = cartResources.split(",");
for (int i = 0; i < cartResource.length; i++)
{
if (StringUtils.notTrimEmpty(cartResource[i]))
{
String[] cartResourceDetail = cartResource[i].split("_");
if (cartResourceDetail.length < 7)
{
continue;
}
String resourceId = cartResourceDetail[0];
if (StringUtils.notTrimEmpty(resourceId))
{
itemMap.put(resourceId, cartResourceDetail[6]);
}
resourceIdList.add(resourceId);
}
}
}
if (resourceIdList != null && resourceIdList.size() > 0)
{
Cart cart = cartService.getCart(resourceIdList);
List<Item> itemList = cart.getItemList();
if (itemList != null && itemList.size() > 0)
{
for (Item item : itemList)
{
Map<String, Object> resourceMap = new HashMap<String, Object>();
resourceMap.put("breedId", item.getBreedCode());
resourceMap.put("breed", item.getBreedName());
resourceMap.put("spec", item.getSpecName());
resourceMap.put("material", item.getMaterialName());
resourceMap.put("weightWayName", item.getWeightWayName());
resourceMap.put("averageQty", item.getAverageQty());
resourceMap.put("items", item.getNumber());
resourceMap.put("onboardPrice", item.getOnboardPrice());
resourceMap.put("onboardItems", item.getOnboardNum());
resourceMap.put("qty", item.getQty());
resourceMap.put("brand", item.getFactoryName());
resourceMap.put("resourceId", item.getResourceId());
resourceMap.put("buyItems", itemMap.get(item.getResourceId()+""));
if (map != null && map.size() > 0 && map.containsKey(item.getGoodsMemberId()))
{
Map<String, Object> orderDivideByGoodsMemberTemp = (Map<String, Object>) map.get(item.getGoodsMemberId());
if (orderDivideByGoodsMemberTemp != null)
{
if (orderDivideByGoodsMemberTemp.containsKey(item.getWarehouseName()))
{
Map<String, Object> resDivideByWarehouseTemp = (Map<String, Object>) orderDivideByGoodsMemberTemp.get(item
.getWarehouseName());
if (resDivideByWarehouseTemp != null && resDivideByWarehouseTemp.containsKey("resourceMapList"))
{
List<Map<String, Object>> resourceMapListTemp = (List<Map<String, Object>>) resDivideByWarehouseTemp
.get("resourceMapList");
if (resourceMapListTemp != null)
{
resourceMapListTemp.add(resourceMap);
resDivideByWarehouseTemp.put("resourceMapList", resourceMapListTemp);
orderDivideByGoodsMemberTemp.put(item.getWarehouseName(), resDivideByWarehouseTemp);
map.put(item.getGoodsMemberId(), orderDivideByGoodsMemberTemp);
}
}
}
else
{
List<Map<String, Object>> resourceMapList = new ArrayList<Map<String, Object>>();
resourceMapList.add(resourceMap);
Map<String, Object> resDivideByWarehouse = new HashMap<String, Object>();
resDivideByWarehouse.put("phone", item.getWarehousePhone());
resDivideByWarehouse.put("address", item.getWarehouseAddress());
resDivideByWarehouse.put("name", item.getWarehouseName());
resDivideByWarehouse.put("resourceMapList", resourceMapList);
resDivideByWarehouse.put("startTime", item.getWarehouseWorkStartTime());
resDivideByWarehouse.put("endTime", item.getWarehouseWorkEndTime());
orderDivideByGoodsMemberTemp.put(item.getWarehouseName(), resDivideByWarehouse);
map.put(item.getGoodsMemberId(), orderDivideByGoodsMemberTemp);
}
}
}
else
{
List<Map<String, Object>> resourceMapList = new ArrayList<Map<String, Object>>();
resourceMapList.add(resourceMap);
Map<String, Object> resDivideByWarehouse = new HashMap<String, Object>();
resDivideByWarehouse.put("phone", item.getWarehousePhone());
resDivideByWarehouse.put("address", item.getWarehouseAddress());
resDivideByWarehouse.put("name", item.getWarehouseName());
resDivideByWarehouse.put("resourceMapList", resourceMapList);
resDivideByWarehouse.put("startTime", item.getWarehouseWorkStartTime());
resDivideByWarehouse.put("endTime", item.getWarehouseWorkEndTime());
Map<String, Object> orderDivideByGoodsMember = new HashMap<String, Object>();
orderDivideByGoodsMember.put("goodsMemberId", item.getGoodsMemberId());
orderDivideByGoodsMember.put("name", item.getGoodsMemberName());
orderDivideByGoodsMember.put(item.getWarehouseName(), resDivideByWarehouse);
map.put(item.getGoodsMemberId(), orderDivideByGoodsMember);
}
}
}
cartResourceInfo = JSONObject.toJSONString(map);
}
return cartResourceInfo;
}