java 實體類 list 怎麼轉map
這是service層的
@Override @Transactional public PageVo<List<Map<String,Object>>> searchOrders(UserVo user, OrderBillVo vo, Map<String,Object> mapParm,int curPage, int pageSize,//String type, String sortname, String sortorder) throws CPServiceException { try { // StringBuffer buffer = new StringBuffer("from OrderBillHisPo where 1=1"); StringBuffer buffer = new StringBuffer("select id, serial_num as serialNum, seq_no as seqNo, " + "batch_id as batchId, item_num as itemNum, mobile, status," + "intention, duration, money, city_id as cityId, province_id as provinceId," + "info, digits, trade_id as tradeId, caller_num as callerNum, back_url as backUrl," + "answer_time as answerTime, end_time as endTime, update_time as updateTime," + "create_time as createTime, text_path as textPath, voice_file as voiceFile, fs_server as fsServer," + "node_path as nodePath, node_end as nodeEnd, user_id as userId, called_num as calledNum," + "called_status as calledStatus, result_type as resultType, result_signs as resultSigns," + "result_content as resultContent, remark from e_order_bill_201809 where 1=1"); //查詢條件改 加下劃線 if (StringUtils.isNotEmpty(vo.getSerialNum())) { buffer.append(" and serial_num='"+vo.getSerialNum()+"' "); } if (StringUtils.isNotEmpty(vo.getSeqNo())) { buffer.append(" and seq_no='"+vo.getSeqNo()+"' "); } //若為普通使用者只能檢視自己的資訊 if(user.getUserType().intValue()!=DictionaryConstants.UserType.SUPADMIN.Value().intValue()){ buffer.append(" and seq_no='"+user.getEntityId()+"' ");//seqNo 客戶編號 } //子賬戶只能檢視自己名下的資訊,賬戶型別:1-主賬戶2-子賬戶3-全域性子賬戶 if(user.getAccType()!=null&&user.getAccType()==2){ buffer.append(" and user_id="+user.getUserId()); } if (StringUtils.isNotEmpty(vo.getBatchId())) { buffer.append(" and batch_id='"+vo.getBatchId()+"' "); } if (StringUtils.isNotEmpty(vo.getItemNum())) { buffer.append(" and item_num='"+vo.getItemNum()+"' ");//itemNum 專案編號 } if (StringUtils.isNotEmpty(vo.getMobile())) { buffer.append(" and mobile='"+vo.getMobile()+"' "); } if (StringUtils.isNotEmpty(vo.getCalledNum())) { buffer.append(" and called_num='"+vo.getCalledNum()+"' ");//calledNum 轉呼號碼 } if (vo.getStatus()!=null) { buffer.append(" and status="+vo.getStatus()+" "); } if (StringUtils.isNotEmpty(vo.getIntentionStr())) { String[] intentionArr = vo.getIntentionStr().split("-"); if(intentionArr.length>1){ int begin=Integer.parseInt(intentionArr[0]); int end=Integer.parseInt(intentionArr[1]); if(begin==0){ buffer.append(" and intention<"+end+" "); }else if(end==100){ buffer.append(" and intention>="+begin+" "); }else{ buffer.append(" and intention>="+begin+" "); buffer.append(" and intention<"+end+" "); } } } if (vo.getDuration()!=null) { buffer.append(" and duration="+vo.getDuration()); } /*if (StringUtils.isNotBlank(vo.getMoney())) { buffer.append(" and duration="+vo.getDuration()); }*/ if (StringUtils.isNotEmpty(vo.getCityId())) { buffer.append(" and city_id='"+vo.getCityId()+"' "); } if (StringUtils.isNotEmpty(vo.getProvinceId())) { buffer.append(" and province_id='"+vo.getProvinceId()+"' "); } if (StringUtils.isNotEmpty(vo.getTradeId())) { buffer.append(" and trade_id='"+vo.getTradeId()+"'"); } if (StringUtils.isNotEmpty(mapParm.get("beginTime").toString())) { buffer.append(" and begin_time >= '"+mapParm.get("beginTime").toString()+"'"); } if (StringUtils.isNotEmpty(mapParm.get("answerTime").toString())) { buffer.append(" and answer_time <= '"+mapParm.get("answerTime").toString()+"'"); } if (StringUtils.isNotEmpty(mapParm.get("startDate").toString())&&StringUtils.isNotEmpty(mapParm.get("endDate").toString())) { buffer.append(" and updateTime between '"+mapParm.get("startDate").toString()+"' and '"+mapParm.get("endDate").toString()+"' "); }else if(StringUtils.isNotEmpty(mapParm.get("startDate").toString())){ buffer.append(" and updateTime >= '"+mapParm.get("startDate").toString()+"'"); }else if(StringUtils.isNotEmpty(mapParm.get("endDate").toString())){ buffer.append(" and updateTime <= '"+mapParm.get("endDate").toString()+"'"); } if (StringUtils.isNotEmpty(mapParm.get("durationBegin").toString())&&StringUtils.isNotEmpty(mapParm.get("durationEnd").toString())) { buffer.append(" and duration between "+mapParm.get("durationBegin")+" and "+mapParm.get("durationEnd")); }else if(StringUtils.isNotEmpty(mapParm.get("durationBegin").toString())){ buffer.append(" and duration >= "+mapParm.get("durationBegin")); }else if(StringUtils.isNotEmpty(mapParm.get("durationEnd").toString())){ buffer.append(" and duration <= "+mapParm.get("durationEnd")); } if (StringUtils.isNotEmpty(sortname)&& StringUtils.isNotEmpty(sortorder)) { buffer.append(" order by "+sortname+" "+sortorder); } else { buffer.append(" order by update_time desc "); } List<OrderBillVo> vos = new ArrayList<OrderBillVo>(); int totalSize = 0; Page<OrderBillHisPo> pagePo = orderHisDaoImpl.pagedByHql(buffer.toString(), curPage, pageSize); List<OrderBillHisPo> pos = pagePo.getList(); totalSize = (int) pagePo.getTotalCount(); for (OrderBillHisPo po : pos) { //ProductVo pvo = this.parseProductPo2Vo(po); OrderBillVo pvo = new OrderBillVo(); BeanUtils.copyProperties(po, pvo); //獲取訂單狀態名稱1-呼叫完成2-呼叫失敗3-未應答4-提交成功5-通話中 -1-其他錯誤 if(po.getStatus()!=null){ pvo.setStatusName(po.getStatus()==1?"呼叫完成":(po.getStatus()==2?"呼叫失敗":(po.getStatus()==3?"未應答":(po.getStatus()==4?"提交成功":(po.getStatus()==5?"通話中":"其他錯誤"))))); } //意向名稱 if(po.getIntention()!=0){ pvo.setIntentionName(po.getIntention()+"%"); }else{ pvo.setIntentionName("0.00%"); } //獲取專案資訊 if(StringUtils.isNotEmpty(po.getItemNum())){ ItemInfoVo ivo = itemInfoServiceImpl.getItemByNum(null, po.getSeqNo(), po.getItemNum()); if(ivo!=null){ pvo.setItemNumName(ivo.getItemName()); }else{ pvo.setItemNumName("未知"); } } //歸屬地 if(StringUtils.isNotEmpty(po.getProvinceId())){ List<Map<String, Object>> listMap = dictionaryServiceImpl.searchProvinceListByProCity(null); Map<String, Object> proMap = null ; for (Map<String, Object> map : listMap) { if(map.containsKey("province_id")&&map.get("province_id")!=null&&map.get("province_id").toString().equals(po.getProvinceId())){ proMap = new HashMap<String, Object>(); proMap.put("province_id", po.getProvinceId()); proMap.put("province_name", map.get("province_name")!=null?map.get("province_name").toString():"某省"); pvo.setProvinceIdName(map.get("province_name").toString()); } } } if(StringUtils.isNotEmpty(po.getCityId())){ List<Map<String, Object>> listMap = dictionaryServiceImpl.searchCityListByProCity(null, po.getProvinceId()); Map<String, Object> proMap = null ; for (Map<String, Object> map : listMap) { if(map.containsKey("city_id")&&map.get("city_id")!=null&&map.get("city_id").toString().equals(po.getCityId())){ proMap = new HashMap<String, Object>(); proMap.put("city_id", vo.getCityId()); proMap.put("city_name", map.get("city_name")!=null?map.get("city_name").toString():"某省"); //vo.setProvinceIdName(map.get("city_name").toString()); pvo.setCityIdName(map.get("city_name").toString()); } } } //獲取商戶名稱 if(StringUtils.isNotEmpty(po.getSeqNo())){ SpInfoVo svo = spInfoServiceImpl.findOneBySpId(null, po.getSeqNo()); pvo.setSeqNoName(svo.getSpname()); } if(StringUtils.isBlank(pvo.getTextPath())){ pvo.setTextPath(""); } //獲取使用者名稱稱 pvo.setUserName(""); if(po.getUserId()!=null){ if(po.getUserId()==0){ pvo.setUserName("API"); }else{ UserVo uvo = userServiceImpl.getUserById(po.getUserId()); pvo.setUserName(uvo!=null?uvo.getUserName():po.getUserId()+""); } } vos.add(pvo); } // } return new PageVo<List<OrderBillVo>>(vos,totalSize,curPage, pageSize); } catch (Exception e) { logger.error("分頁查詢訂單列表失敗:" + e.getMessage()); throw new CPServiceException("分頁查詢訂單列表失敗:" + e.getMessage()); } }