惠安惠達專案新需求:首頁增加待命車明細

ZHOU_VIP發表於2017-05-27

點選待命車,希望看到明細資訊

增加程式碼:


@RequestMapping(value = "/summaryHostVehInfo", method = RequestMethod.GET)
@ResponseBody
public BaseResp summaryHostVehInfo(){
	AbstractRequestExecutor executor = new AbstractRequestExecutor("請求訪問待命車輛資訊查詢介面", "query summaryInfo"){
		@Override
		protected BaseResp queryDetail(String key) throws Exception{
			return messageService.querySummaryHostVehInfo();
		}
	};
	
	return executor.executeQueryDetail("");
}

ListResp querySummaryHostVehInfo();

@Override
public ListResp querySummaryHostVehInfo(){
    ListResp resp = new ListResp();
    
    List<VehUseSummaryInfoResp> summaryInfoResp = new ArrayList<VehUseSummaryInfoResp>(); ;
    
    summaryInfoResp =vehUseMessageDao.querySummaryHostVehInfo();
    
    resp.setList(summaryInfoResp);
    
    return resp;
}

List<VehUseSummaryInfoResp> querySummaryHostVehInfo();

@Override
public List<VehUseSummaryInfoResp> querySummaryHostVehInfo(){
    HibernateParams hParams = new HibernateParams();
    OrgDeptSearchFilter helper = new OrgDeptSearchFilter();
    UserSysDeptRes userSysDeptRes = Common.getLoginInfo().getUserSysDept();
    Integer querySysId = userSysDeptRes.getAppSysId();
    Integer queryDeptId = userSysDeptRes.getAppDeptId();
    
    hParams.addSqlStrBuffer("select m.item_name hostVehType,count(m.item_name) hostVehTypeCount from ");
    hParams.addSqlStrBuffer("(select b.item_name,v.* from vd_veh_assign_list v inner join ");
    hParams.addSqlStrBuffer("(select t.hostid,t.HOST_VEH_TYPE,t.owner_appsysid,t.owner_appdeptid, a.item_name ");
    hParams.addSqlStrBuffer("  from position_host_info_extend t, DICTIONARY_ITEM a ");
    hParams.addSqlStrBuffer(" where a.dic_type = 'HOST_VEH_TYPE' ");
    hParams.addSqlStrBuffer("and t.host_veh_type = a.item_value)b on v.host_id=b.hostid ");
    hParams.addSqlStrBuffer("and v.execute_status=").addSqlStrBuffer(Constant.ASSIGN_EXECUTE_STATUS_NOEXECUTE.toString())
    .addSqlStrBuffer(" and ((b.owner_appsysid, b.owner_appdeptid) in( ")
    .addSqlStrBuffer(helper.getSubDeptSql(querySysId, queryDeptId, hParams))
    .addSqlStrBuffer(" )))m group by m.item_name ");
    List<VehUseSummaryInfoResp> list = findBySql(hParams.getSqlStr(), hParams.getParamObj(), VehUseSummaryInfoResp.class);
    return list;
}

sql語句:



介面測試OK:


2017.6.6補充:上面的sql查詢的資料不對,待命車輛數超過了車輛總數

發現關聯的表不對,修改sql如下:


程式碼:




相關文章