📄 plandaoimpl.java
字号:
/* 创建日期:Dec 11, 2006
* 作 者:朱 闰
* 公 司:安徽通途信息技术有限公司
*/
package com.tongtu.Dao.plan.planDao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.tongtu.Dao.plan.PlanDAO;
import com.tongtu.Dao.role.RoleDAO;
import com.tongtu.Dao.role.roleDao.RoleDAOImpl;
import com.tongtu.comm.sql.DBConnectionManager;
import com.tongtu.comm.sql.DBOperator;
import com.tongtu.util.City;
import com.tongtu.util.CurrentUser;
import com.tongtu.util.Page;
import com.tongtu.util.PlanDetail;
import com.tongtu.util.QueryStr;
import com.tongtu.util.TotalInfo;
import com.tongtu.util.UserInfo;
public class PlanDAOImpl implements PlanDAO{
/**
* 添加计划的详细信息
*/
public boolean addPlanInfo(PlanDetail pd) {
DBOperator dbo = new DBOperator();
String query = "insert into tt_plandetail(planType,roadName,townsId,townName,villagesId,villageName,milemeter," +
"invest,provincesubsidy,qdmc,qdloc,zjd1mc,zjd1loc,zjd2mc,zjd2loc,zjd3mc,zjd3loc,zdmc,zdloc,lc_xz,ljkd_xz,lmkd_xz,lmlx_xz," +
"rk,sr,jjzw,AttachFile,graphicFile,createtime ) values(";
query += pd.getPlanType() + ",'";
query += pd.getRoadName() + "','";
query += pd.getTownsId() + "','";
query += pd.getTownName() + "','";
query += pd.getVillagesId() + "','";
query += pd.getVillageName() + "',";
query += pd.getMilemeter() + ",";
query += pd.getInvest() + ",";
query += pd.getProvinceSubsidy()+",'";
query += pd.getQdmc()+ "','";
query += pd.getQdloc()+ "','";
query += pd.getZjd1mc()+ "','";
query += pd.getZjd1loc()+ "','";
query += pd.getZjd2mc()+ "','";
query += pd.getZjd2loc()+ "','";
query += pd.getZjd3mc()+ "','";
query += pd.getZjd3loc()+ "','";
query += pd.getZdmc()+ "','";
query += pd.getZdloc()+ "',";
query += pd.getLc_xz()+ ",";
query += pd.getLjkd_xz()+ ",";
query += pd.getLmkd_xz()+ ",'";
query += pd.getLmlx_xz()+ "',";
query += pd.getRk()+ ",";
query += pd.getSr()+ ",'";
query += pd.getJjzw()+ "','";
query += pd.getAttachFile()+ "','";
query += pd.getGraphicFile()+ "',curdate())";
try {
System.out.println(query);
dbo.setPrepareStatement(query);
dbo.executeUpdate();
return true;
} catch (Exception e) {
} finally {
dbo.close();
}
return false;
}
/**
* 根据行政区划分页显示地区计划路线
*/
public Page getPlanListById(int start, int count, String bianMa,QueryStr qs) {
DBOperator dbo = new DBOperator();
List planList = new ArrayList();
Page page = null;
try {
String queryStr = "select planid,plantype,ProvinceSubsidy,attachFile," +
" graphicFile,endTime,startTime,invest,milemeter,note,roadbedwidth,roadName,roadsurfaceType," +
"roadsurfacewidth,townsId,villagesId,villageType,villageName,townName " +
" from tt_plandetail where townsId like '%" + bianMa + "%' ";
queryStr += " order by " ;
if (qs.getTypeId() == 6) {
if (qs.getStartType() == 1)
queryStr += " startTime asc ";
else
queryStr += " startTime desc ";
}
if (qs.getTypeId() == 7) {
if (qs.getEndType() == 1)
queryStr += " endTime asc ";
else
queryStr += " endTime desc ";
}
if (qs.getTypeId() == 1) {
if (qs.getMileType() == 1)
queryStr += " Milemeter asc ";
else
queryStr += " Milemeter desc ";
}
if (qs.getTypeId() == 2) {
if (qs.getLjkdType() == 1)
queryStr += " roadbedwidth asc ";
else
queryStr += " roadbedwidth desc ";
}
if (qs.getTypeId() == 3) {
if (qs.getLmkdType() == 1)
queryStr += " roadsurfacewidth asc ";
else
queryStr += " roadsurfacewidth desc ";
}
if (qs.getTypeId() == 4) {
if (qs.getInvestType() == 1)
queryStr += " Invest asc ";
else
queryStr += " Invest desc ";
}
if (qs.getTypeId() == 5) {
if (qs.getProType() == 1)
queryStr += " provincesubsidy asc ";
else
queryStr += " provincesubsidy desc ";
}
if (qs.getTypeId() == 8) {
if (qs.getRoadType() == 1)
queryStr += " roadname asc ";
else
queryStr += " roadname desc ";
}
if (qs.getTypeId() == 9) {
if (qs.getJhType() == 1)
queryStr += " planType asc ";
else
queryStr += " planType desc ";
}
if (qs.getTypeId() == 10) {
if (qs.getTownType() == 1)
queryStr += " townName asc ";
else
queryStr += " townName desc ";
}
if (qs.getTypeId() == 11) {
if (qs.getCunType() == 1)
queryStr += " villageName asc ";
else
queryStr += " villageName desc ";
}
if (qs.getTypeId() == 12) {
if (qs.getCityType() == 1)
queryStr += " townsid asc ";
else
queryStr += " townsid desc ";
}
queryStr += "LIMIT "+start + ", 10";
System.out.println(queryStr);
dbo.setPrepareStatement(queryStr);
ResultSet rs = dbo.executeQuery();
while (rs.next()) {
PlanDetail pd = new PlanDetail();
pd.setPlanId(rs.getInt("planId"));
pd.setPlanType(rs.getInt("planType"));
pd.setProvinceSubsidy(rs.getDouble("ProvinceSubsidy"));
pd.setAttachFile(rs.getString("attachFile"));
pd.setGriphicFile(rs.getString("graphicFile"));
pd.setEndTime(CurrentUser.getDateToString(rs.getDate("endTime")));
pd.setStartTime(CurrentUser.getDateToString(rs.getDate("startTime")));
pd.setInvest(rs.getDouble("invest"));
pd.setMilemeter(rs.getDouble("milemeter"));
pd.setNote(rs.getString("note"));
pd.setRoadbedWidth(rs.getDouble("roadbedwidth"));
pd.setRoadName(rs.getString("roadName"));
pd.setRoadSurfaceType(rs.getInt("roadsurfaceType"));
pd.setRoadSurfaceWidth(rs.getDouble("roadsurfacewidth"));
pd.setTownsId(rs.getString("townsId"));
String cityCode = rs.getString("townsId").substring(0,4)+"00000000";
String countyCode = rs.getString("townsId");
// System.out.println("cityCode==" + cityCode + " countyCode===" + countyCode);
String cityName = City.getCityNameByNum(cityCode);
String countyName = City.getCountyName(countyCode);
pd.setCityName(cityName);
pd.setCountyName(countyName);
pd.setVillagesId(rs.getString("villagesId"));
pd.setVillageType(rs.getString("villageType"));
pd.setVillageName(rs.getString("villageName"));
pd.setTownName(rs.getString("townName"));
planList.add(pd);
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
dbo.close();
}
page = new Page(planList, start, true);
return page;
}
/**
* 根据用户所在地编码获取计划总数
*/
public int getPlanCountById(String bianMa) {
ArrayList articlelist=new ArrayList();
int count=0;
DBOperator dbo = new DBOperator();
try {
String sqlStr = "select count(planId) as maxCount from tt_plandetail where townsId like '%" + bianMa + "%' order by createtime desc";
dbo.setPrepareStatement(sqlStr);
ResultSet rs = dbo.executeQuery();
while (rs.next()) {
count = rs.getInt("maxCount");
}
rs.close();
return count;
} catch (SQLException e) {
e.printStackTrace();
} finally {
dbo.close();
}
return count;
}
/**
* 根据计划ID获取计划信息
*/
public PlanDetail getPlanInfoById(int planId) {
DBOperator dbo = new DBOperator();
PlanDetail pd = new PlanDetail();
RoleDAO roledao = new RoleDAOImpl();
try {
String sqlStr = "select planid,plantype,ProvinceSubsidy,attachFile, graphicFile" +
" ,endTime,startTime,invest,milemeter,note,roadbedwidth,roadName,roadsurfaceType," +
"roadsurfacewidth,townsId,villagesId,villageType,villageName,townName ," +
"isPKX,isMZDQ,isgmlq,jsxz,jsdj,ql,ljwctz,zytz,zytzcgs,zygz,ssqzc,gndk," +
"zyjsnr,qqgzjz,sjjslc,sjwctze,jhlx,txzmc,tjzcmc,jhyear " +
" from tt_plandetail where planId= " + planId;
System.out.println(sqlStr);
dbo.setPrepareStatement(sqlStr);
ResultSet rs = dbo.executeQuery();
while (rs.next()) {
pd.setPlanId(rs.getInt("planId"));
pd.setPlanType(rs.getInt("planType"));
pd.setProvinceSubsidy(rs.getDouble("ProvinceSubsidy"));
pd.setAttachFile(rs.getString("attachFile"));
pd.setGriphicFile(rs.getString("graphicFile"));
pd.setEndTime(CurrentUser.getDateToString(rs.getDate("endTime")));
pd.setStartTime(CurrentUser.getDateToString(rs.getDate("startTime")));
pd.setInvest(rs.getDouble("invest"));
pd.setMilemeter(rs.getDouble("milemeter"));
pd.setNote(rs.getString("note"));
pd.setRoadbedWidth(rs.getDouble("roadbedwidth"));
pd.setRoadName(rs.getString("roadName"));
pd.setRoadSurfaceType(rs.getInt("roadsurfaceType"));
pd.setRoadSurfaceWidth(rs.getDouble("roadsurfacewidth"));
pd.setTownsId(rs.getString("townsId"));
String cityCode = rs.getString("townsId").substring(0,4)+"00000000";
String countyCode = rs.getString("townsId");
// System.out.println("cityCode==" + cityCode + " countyCode===" + countyCode);
String cityName = City.getCityNameByNum(cityCode);
String countyName = City.getCountyName(countyCode);
pd.setCityName(cityName);
pd.setCountyName(countyName);
pd.setVillagesId(rs.getString("villagesId"));
pd.setVillageType(rs.getString("villageType"));
pd.setVillageName(rs.getString("villageName"));
pd.setTownName(rs.getString("townName"));
//新增字段
pd.setIsPKX(rs.getInt("isPKX"));
pd.setIsMZDQ(rs.getInt("isMZDQ"));
pd.setIsGMLQ(rs.getInt("isgmlq"));
pd.setJsxz(rs.getInt("jsxz"));
pd.setJsdj(rs.getInt("jsdj"));
pd.setQl(rs.getString("ql"));
pd.setLjwctz(rs.getDouble("ljwctz"));
pd.setZytz(rs.getDouble("zytz"));
pd.setZytzcgs(rs.getDouble("zytzcgs"));
pd.setZygz(rs.getDouble("zygz"));
pd.setSsqzc(rs.getDouble("ssqzc"));
pd.setGndk(rs.getDouble("gndk"));
pd.setZyjsnr(rs.getInt("zyjsnr"));
pd.setSjjslc(rs.getDouble("sjjslc"));
pd.setSjwctze(rs.getDouble("sjwctze"));
pd.setJhlx(rs.getInt("jhlx"));
pd.setTxzmc(rs.getString("txzmc"));
pd.setQqgzjz(rs.getString("qqgzjz"));
pd.setTjzcmc(rs.getString("tjzcmc"));
pd.setJhyear(rs.getInt("jhyear"));
}
rs.close();
// CurrentUser.saveLog(sqlStr); //保存当前用户操作记录
return pd;
} catch (SQLException e) {
e.printStackTrace();
} finally {
dbo.close();
}
return null;
}
/**
* 根据计划ID更新计划信息
*/
public boolean updatePlanInfo(PlanDetail pd, int planId) {
DBOperator dbo = new DBOperator();
String query = "update tt_plandetail set planType = ";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -