📄 pldrvalidatebean.java
字号:
package com;
import java.sql.*;
import java.util.*;
import com.jstrd.util.DBConnection;
import com.jstrd.gdzc.comm.GdzcDate;
import com.jstrd.gdzc.wrzkp.kprz.DateCom;
public class PLDRValidateBean {
private DBConnection db = null;
public PLDRValidateBean(DBConnection dbc) throws Exception {
try {
this.db=dbc;
//conn = db.getConnection();
} catch (Exception e) {
new Exception("获取数据库连接出错");
}
}
//判断卡片性质(k_kpxz=1)
public boolean validateKpxz(int k_kpxz) throws Exception {
if (k_kpxz != 1) {
throw new Exception("卡片性质要求等于1");
}
return true;
}
// 判断资产类型
public boolean validateZclx(int k_zclx) throws Exception {
if (!(k_zclx==1 || k_zclx==2 || k_zclx==3 || k_zclx==4||k_zclx==9)) {
throw new Exception("资产类型只能为1、2、3、4、9");
}
return true;
}
//判断原卡片编号是否存在
public boolean validateYkpbh(long k_ykpbh, String tableName)
throws Exception {
String sql =
"select count(*) from " + tableName + " where k_kpbh =" + k_ykpbh;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("原卡片编号不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断资产目录的存在性---通过判断该资产目录在gd_zcmlb中是否存在
public boolean validateZcml(String k_zcml) throws Exception {
// if ((k_zcml.substring(0, 3)).equals("011")) {
// throw new Exception("不允许导入土地资产");
// }
if (!((k_zcml.length() >= 7 && k_zcml.length() <= 11)||(k_zcml.length()==6))) {
throw new Exception("资产目录格式不正确");
}
return true;
}
//判断资产分类的存在性
public boolean validateZcfl(int k_zcfl) throws Exception {
String sql = "select count(*) from gd_zcflb where k_zcfl = " + k_zcfl;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("资产目录不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断网元属性是否存在
public boolean validateWysx(String wysx) throws Exception {
String sql = "select count(*) from gd_cpsxb where k_cpsx = '" + wysx+"'";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("网元属性不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断单位编号是否存在
public boolean validateDwbh(String k_dwbh) throws Exception {
String sql = "select count(*) from gd_dsdwb where k_dwbh = '" +k_dwbh+"' ";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("单位编号不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断资产归属的存在性
public boolean validateZcgs(int k_zcgs) throws Exception {
String sql = "select count(*) from gd_zcgsb where k_zcgs = " + k_zcgs;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("资产归属不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断专业归属的存在性
public boolean validateZygs(int k_zygs) throws Exception {
String sql = "select count(*) from gd_zygsb where k_zygs =" + k_zygs;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("资产归属专业不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断资产状态的存在性
public boolean validateZczt(int k_zczt) throws Exception {
String sql = "select count(*) from gd_zcztb where k_zczt = " + k_zczt;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("资产状态不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断折旧年限是否符合资产目录对应的折旧年限
public boolean validateZjnx(String k_zcml, int k_zjnx) throws Exception {
String sql =
"select count(*) from gd_zcmlb where k_zcml = '"
+ k_zcml
+ "'"
+ " and k_zjnx ="
+ k_zjnx;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("折旧年限不符合资产目录对应的折旧年限");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//资产原值(k_yz double) 不可为0,同时小数点后最多两位
public boolean validateYz(double k_yz) throws Exception {
if (k_yz == 0) {
throw new Exception("资产原值不可为0");
}
String temp = String.valueOf(k_yz);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("资产原值小数点后最多两位");
}
return true;
}
//资产净值(k_jz double )不可为0,同时小数点后最多两位
public boolean validateJz(double k_jz) throws Exception {
if (k_jz == 0) {
throw new Exception("资产净值不可为0");
}
String temp = String.valueOf(k_jz);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("资产净值小数点后最多两位");
}
return true;
}
public boolean validateJz_kpth(String k_jz) throws Exception {
//if (k_jz == 0) {
// throw new Exception("资产净值不可为0");
//}
String temp = String.valueOf(k_jz);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("资产净值小数点后最多两位");
}
return true;
}
public boolean validateJcz_kpth(String k_jz) throws Exception {
//if (k_jz == 0) {
// throw new Exception("资产净值不可为0");
//}
String temp = String.valueOf(k_jz);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("资产净残值小数点后最多两位");
}
return true;
}
//累计折旧(k_ljzj double(18,2) 判断
public boolean validateLjzj(double k_ljzj, int k_zjnx, int k_sksynx)
throws Exception {
String temp = String.valueOf(k_ljzj);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("累计折旧小数点后最多两位");
}
if (k_zjnx * 12 != k_sksynx) {
if (k_ljzj == 0.0) {
throw new Exception("累计折旧不能为零");
}
return true;
} else {
if (k_ljzj != 0.0) {
throw new Exception("累计折旧应为零");
}
return true;
}
}
public boolean validateLjzj_kpth(String k_ljzj)
throws Exception {
String temp = String.valueOf(k_ljzj);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("累计折旧小数点后最多两位");
}
return true;
}
//月折旧额(k_yzje double(18,2) 不可为0.00
public boolean validateYzje(double k_yzje) throws Exception {
if (k_yzje == 0.0) {
throw new Exception("月折旧额不可为零");
}
String temp = String.valueOf(k_yzje);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("累计折旧小数点后最多两位");
}
return true;
}
public boolean validateYzje_kpth(String k_yzje) throws Exception {
//if (k_yzje == 0.0) {
// throw new Exception("月折旧额不可为零");
//}
String temp = String.valueOf(k_yzje);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("累计折旧小数点后最多两位");
}
return true;
}
//判断会计科目的存在性
public boolean validateKmdh(String k_kmdh) throws Exception {
String sql =
"select count(*) from gd_kmdhb where k_kmdh = '" + k_kmdh + "'";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("会计科目不存在性");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//数量不可为零
public boolean validateSl(double k_sl) throws Exception {
if (k_sl == 0.0) {
throw new Exception("数量不可为零");
}
String temp = String.valueOf(k_sl);
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 4) {
throw new Exception("资产数量小数点后最多肆位");
}
return true;
}
//判断使用部门编号是否存在
public boolean validateSybm(String k_sybm, String k_dwbh)
throws Exception {
String sql =
"select count(*) from gd_dsbmb where k_dwbh = '"
+ k_dwbh
+ "'"
+ " and k_bmbh = '"
+ k_sybm
+ "'";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("使用部门编号不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断专业部门编号是否存在
public boolean validateGlbm(String k_glbm, String k_dwbh)
throws Exception {
String sql =
"select count(*) from gd_dsbmb where k_dwbh = '"
+ k_dwbh
+ "'"
+ " and k_bmbh = '"
+ k_glbm
+ "'";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("专业部门编号不存在");
}
} else {
rs.close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -