7개 테이블의 복잡한 조회
5585 단어 조회
public List findDetailSumById(Long id) throws Exception {
List sumList=new ArrayList();
StringBuffer sb = new StringBuffer(" ");
sb.append("select sup.materialcode as materialcode,sup.materialname as materialname,sup.is_auto_send_erp,");
sb.append("sup.providerproductname as providerproductname , sup.measurename as measurename,");
sb.append("sum(sup.amount) as amount,sum(sup.money) as money,");
sb.append("sup.providername as providername, sup.locationname as locationname,");
sb.append("sup.projectcode as projectcode,sup.materialproperty as materialproperty,");
sb.append("sup.providerproductcode as providerproductcode, sup.submeasurename as submeasurename,");
sb.append("sup.providershortname as providershortname ,");
sb.append("sup.ismainproduct as ismainproduct,sup.inlocationname as inlocationname");
sb.append(" from");
sb.append("(");
sb.append("select spm.entity_code as materialcode,spm.entity_name as materialname,sibd.is_auto_send_erp ,");
sb.append("sibd.provider_product_name as providerproductname,sibd.is_main_product as ismainproduct,");
sb.append(" nvl( sibd.measure_name,' ') as measurename,nvl( sibd.sub_measure_name,' ') as submeasurename,");
sb.append("nvl(sibd.amount,0) as amount,nvl(sibd.money,0) as money,");
sb.append(" spr.entity_name as providername,spr.short_name as providershortname ,nvl(swl.entity_name,' ') as locationname ,");
sb.append(" nvl( sibd.entity_desc,' ') as entitydesc,nvl( sp.entity_code,' ') as projectcode,");
sb.append(" nvl( sibd.provider_product_code,' ') as providerproductcode,nvl( smp.entity_name,' ') as materialproperty,");
sb.append(" sibd.output_bill_id as outputbillid,nvl(swlin.entity_name,' ') as inlocationname");
sb.append(" from scm_output_bill_detail sibd");
sb.append(" left outer join scm_product_material spm on spm.id =sibd.product_material_id");
sb.append(" left outer join scm_provider spr on spr.id = sibd.provider_id");
sb.append(" left outer join scm_warehouse_location swl on swl.id =sibd.warehouse_location_id");
sb.append(" left outer join scm_warehouse_location swlin on swlin.id =sibd.in_warehouse_location_id");
sb.append(" left outer join scm_project sp on sp.id = sibd.project_id");
sb.append(" left outer join scm_material_property smp on smp.id=sibd.material_property_id");
sb.append(") sup");
sb.append(" where sup.outputbillid=?");
sb.append(" group by");
sb.append(" sup.materialcode,sup.materialname,sup.materialproperty, sup.measurename,sup.projectcode,");
sb.append("sup.providername,sup.providerproductname,sup.providerproductcode,sup.locationname,sup.is_auto_send_erp ,");
sb.append("sup.providershortname,sup.submeasurename,sup.ismainproduct,sup.inlocationname");
sb.append(" order by");
sb.append(" sup.materialcode,sup.materialname,sup.materialproperty,sup.measurename,sup.projectcode,");
sb.append("sup.providername,sup.providerproductname,sup.providerproductcode,sup.locationname,");
sb.append("sup.submeasurename,sup.providershortname");
sumList = getJdbcTemplate().query(sb.toString(), new Object[]{id}, new RowMapper(){
public Object mapRow(ResultSet rt, int arg1) throws SQLException {
OutputDetailSumBean outDetailSumBean=new OutputDetailSumBean();
outDetailSumBean.setMaterialCode(rt.getString("materialcode"));
outDetailSumBean.setMaterialName(rt.getString("materialname"));
outDetailSumBean.setProjectCode(rt.getString("projectcode"));
outDetailSumBean.setProviderProductName(rt.getString("providerproductname"));
outDetailSumBean.setMaterialProperty(rt.getString("materialproperty"));
outDetailSumBean.setSubmeasureName(rt.getString("submeasurename"));
outDetailSumBean.setProviderProductCode(rt.getString("providerproductcode"));
outDetailSumBean.setProviderShortName(rt.getString("providershortname"));
outDetailSumBean.setProviderName(rt.getString("providername"));
outDetailSumBean.setLocationName(rt.getString("locationname"));
outDetailSumBean.setInlocationName(rt.getString("inlocationname"));
outDetailSumBean.setMeasureName(rt.getString("measurename"));
outDetailSumBean.setIsmainProduct(rt.getLong("ismainproduct"));
outDetailSumBean.setAmount(rt.getDouble("amount"));
// outDetailSumBean.setPrice(rt.getDouble("price"));
outDetailSumBean.setMoney(rt.getDouble("money"));
outDetailSumBean.setIsAutoSendERP(rt.getLong("is_auto_send_erp"));
return outDetailSumBean;
}
});
return sumList;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Hibernate의 다중 테이블 조회 및 캡처 정책[내부 연결] [외부 연결] 왼쪽 외부 연결: left outer join Select * from A left outer join B on 조건; 오른쪽 외부 연결:right outer join Select * f...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.