/**
* 明細のリスト項目は、次に従い取得する。
* time:2012/11/02
* author:GaoWenguo
* @param kokyakuID ログイン者=お客様ID
* @return TH_HACHU_EXTList 発注明細データ
* 大写的字段为数据库内字段,小写字段为model层定义的结构体变量
*/
@SuppressWarnings("unchecked")
public List<TH_HACHU_EXT> selectThHachu(String kokyakuID) {
String hql=
"select t1.HACHU_YMD \"hachu_Ymd\", " + //依頼日時
"t1.SHONIN_KBV \"shonin_Kbv\", " + //審議区分
"t3.TANTO_NMV \"tanto_Nmv\", "+ //担当者名
"t1.KOKYAKU_ID \"kokyaku_Id\", "+ //お客様ID
"t4.KAISHA_NMV \"kaisha_Nmv\", "+ //会社名
"t4.BUSHO_NMV \"busho_Nmv\", " + //部署名
"t4.KTANTO_NMV \"ktanto_Nmv\", " + //担当者
"m1.SHOHIN_NMV \"shohin_Nmv\", " + //商品名
"m1.MAKER_NMV \"maker_Nmv\", " + //メーカー
"m1.KATA_NOV \"kata_Nov\", " + //型番
"TO_CHAR(m1.TEIKA_KIN,'999,999,999') AS \"teika_Kin\", " + //定価
"TO_CHAR((m1.TEIKA_KIN * t2.SURYO_NUM),'999,999,999,999,999') AS \"subTotal\", " + //小計
"t2.SURYO_NUM \"suryo_Num\", " + //数量
"m1.HACHUTANI_NMV \"hachutani_Nmv\", " + //発注受注単位
"t2.NOHIN_YMD \"nohin_Ymd\", " + //見込納期
"m1.BIKO_NMV \"biko_Nmv\", " + //備考
"t1.HACHU_CDV \"hachu_Cdv\" "; //発注番号
// HQL文
StringBuffer hqlStr = new StringBuffer();
hqlStr.append(" from TH_HACHU t1, TH_HACHU_M t2, M_SHOHIN m1, TH_IDJYOHO t3, TH_CHOKUSOU t4 where ");
hqlStr.append(" t1.HACHU_CDV=t2.HACHU_CDV ");
hqlStr.append(" and t1.KOKYAKU_ID=t3.KOKYAKU_ID ");
hqlStr.append(" and t1.KOKYAKU_ID=t4.KOKYAKU_ID ");
hqlStr.append(" and t1.NOHINTO_CDVS=t4.SITEN_CDV ");
hqlStr.append(" and t2.SHOHIN_CDV=m1.SHOHIN_CDV ");
hqlStr.append(" and t1.SHONIN_KBV='0' ");
hqlStr.append(" and t1.CANCEL_FLG='0' ");
hqlStr.append(" and t1.KARI_FLG='0' ");
hqlStr.append(" and t2.TORIKESHI_FLG='0' ");
hqlStr.append(" and t1.SHINGI_ID=:kokyaku_id ");
hqlStr.append(" order by t1.HACHU_CDV,t4.KAISHA_NMV,t4.BUSHO_NMV,t4.KTANTO_NMV,t2.LINE_NON ");
// 抽出結果のデータリストをリターン
String sql = hql + hqlStr;
return this.getHibernateTemplate().getSessionFactory()
.getCurrentSession().createSQLQuery(sql.toString())
.setString("kokyaku_id", kokyakuID)
.setResultTransformer(Transformers.aliasToBean(TH_HACHU_EXT.class))
.list();
}