常用语句3

1

Service层:

import wfc.facility.tool.autocode.PaginationArrayList;
import wfc.service.database.BlobHelper;
import wfc.service.database.Condition;
import wfc.service.database.Conditions;
import wfc.service.database.RecordSet;
import wfc.service.database.SQL;
import wfc.service.util.CloneHelper;

 

public RecordSet queryPtVisitCountryAndEn(Conditions conds, String strOrder) {
  conds.add(new Condition("t." + TPtVisitCountry.ST_COUNTRY + "= d." + TCountry.ST_NAME_SHORT_CN + "(+) "));
  String sql = "select d." + TCountry.ST_NAME_SHORT_EN + ",d." + TCountry.ST_NAME_SHORT_CN + " ,t.* from T_PT_VISIT_COUNTRY t,T_COUNTRY d where " + conds.toString()
    + (null != strOrder && !"".equals(strOrder) ? "order by " + strOrder : "");
  Object[] obj = conds.getObjectArray();
  return SQL.execute(sql, obj);
 }

Control层

RecordSet visitCountryRs = pvTeamService.queryPtVisitCountryAndEn(conds, "NM_ORDER");

 

String startDateStr = "";

String[] countryName = null;
  if ( null != visitCountryRs && visitCountryRs.TOTAL_RECORD_COUNT > 0 ) {
   countryName = new String[visitCountryRs.TOTAL_RECORD_COUNT];
   int i = 0;
   while (visitCountryRs.next()) {
    countryName[i] = visitCountryRs.getHTMLString("ST_COUNTRY");
    if ( i == 0 ) {
        startDateStr = visitCountryRs.getHTMLString("DT_ARRIVE", "yyyy-MM-dd");
    }
        i++;
   }
}

 

2

HashMap memberMap = new HashMap();

String dontGoStr = "";
  if ( null != memberMap ) {
   Iterator keyItr = memberMap.keySet().iterator();
   while (keyItr.hasNext()) {
    String keyStr = (String)keyItr.next();
    String valueStr = (String)memberMap.get(keyStr);
    for (int i = 0; i < countryName.length; i++) {
     if ( valueStr.indexOf(countryName[i]) < 0 ) {
      dontGoStr += keyStr + "不去" + countryName[i] + ",";
     }
    }
   }
  }

 

3

【service层:】

public String queryVistDays(String stPvTeamId) {
  String sql = "select caculate_days(min(DT_ARRIVE),max(DT_LEAVE)) as VISIT_DAYS from T_PT_VISIT_COUNTRY where ST_PV_TEAM_ID=?";
  RecordSet rs = SQL.execute(sql, new Object[] { stPvTeamId });
  String visitdays = "";
  while (rs.next()) {
   visitdays = rs.getString("VISIT_DAYS");
  }
  return visitdays;
 }

 

【数据库:】

create or replace function caculate_days(begintime timestamp,endtime timestamp) return integer
--计算间隔天数
is
begin
    return to_date(to_char(endtime,'yyyy-mm-dd'),'yyyy-mm-dd')-to_date(to_char(begintime,'yyyy-mm-dd'),'yyyy-mm-dd')+1;
end;

 

 

【service层:】

// 获取出访国家及其英文名字
 public RecordSet queryPtVisitCountryAndEn(Conditions conds, String strOrder) {
  conds.add(new Condition("t." + TPtVisitCountry.ST_COUNTRY + "= d." + TCountry.ST_NAME_SHORT_CN + "(+) "));
  String sql = "select d." + TCountry.ST_NAME_SHORT_EN + ",d." + TCountry.ST_NAME_SHORT_CN + " ,t.* from T_PT_VISIT_COUNTRY t,T_COUNTRY d where " + conds.toString()
    + (null != strOrder && !"".equals(strOrder) ? "order by " + strOrder : "");
  Object[] obj = conds.getObjectArray();
  return SQL.execute(sql, obj);
 }

 

【control层:】

RecordSet visitCountryRs = pvTeamService.queryPtVisitCountryAndEn(conds, "NM_ORDER");

你可能感兴趣的:(常用语句3)