📄 agent.java
字号:
/**
* 代理人
* modify by feizhigao 2008-4-9 add starlevel
*/
package com.NCL;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import jxl.Sheet;
import jxl.Workbook;
import com.sinosoft.common.DBAccess;
import com.sinosoft.common.Data;
import com.sinosoft.common.IndexMap;
import com.sinosoft.common.Md5;
import com.sinosoft.user.*;
public class Agent {
protected IndexMap propList;
protected HashSet Property;
private List strList = new ArrayList();
private boolean EOF = false;
private int COUNT;
private String openStaticMsg;
/**
* 构造函数
*
*/
public Agent() {
propList = new IndexMap();
Property = new HashSet();
Property.add("AgentCode"); //业务员号
Property.add("Name"); //业务员姓名
Property.add("Password"); //密码
Property.add("ComCode"); //管理机构代码
Property.add("ComName"); //管理机构
Property.add("BranchAttr"); //展业机构外部代码
Property.add("BranchName"); //展业机构
Property.add("BirthDay"); //出生日期
Property.add("Age"); //年龄
Property.add("Sex"); //性别 (0是男 1是女)
Property.add("Degree"); //学历
Property.add("IDNo"); //身份证号
Property.add("DevNoFST"); //展业证号
Property.add("HomeAddress"); //现住址
Property.add("ZipCode"); //邮政编码
Property.add("Phone"); //固定电话
Property.add("Mobile"); //手机
Property.add("Email"); //电子邮件
Property.add("OpenStatic"); //开通状态 0为未开通 1为开通
Property.add("AgentStatic"); //优秀状态 0为普通代理人 1为优秀代理人
Property.add("QuafNo"); //代理证号
Property.add("AgentGradeCode"); //级别代码
Property.add("AgentGrade"); //级别
Property.add("StarLevel"); //星级评定
}
/**
* 初始化
* @param AgentCode 代理人号码
*/
public void init(String AgentCode){
DBAccess d = new DBAccess();
String sql = "SELECT * from Agent where AgentCode=?";
this.propList = d.init(sql,AgentCode,this.Property);
}
/**
* 创建代理人
* @return boolean
*/
public boolean createAgent(){
String sql = "INSERT into Agent(AgentCode,Name,Password,ComCode,ComName,BranchAttr,BranchName,BirthDay,Age,Sex," +
"Degree,IDNo,QuafNo,DevNoFST,HomeAddress,ZipCode,Phone,Mobile,Email,AgentGradeCode," +
"AgentGrade,StarLevel) values (?,?,?,?,?,?,?,to_date(?,'yyyy-MM-dd'),?,?,?,?,?,?,?,?,?,?,?,?,?,'0')";
DBAccess d = new DBAccess();
return d.execute(sql,this.propList);
}
/**
* 根据条件查询代理人
* @param a 对象
* @param pageSize 分页大小
* @param pageIndex 分页页码
* @return
*/
public String findAgent(Agent a,int pageSize,int pageIndex){
String result = "";
StringBuffer SQL = new StringBuffer("SELECT AgentCode from Agent where 1=1");
String agentCode = a.get("AgentCode");
String name = a.get("Name");
String openStatic = a.get("OpenStatic");
String agentStatic = a.get("AgentStatic");
String IDNo = a.get("IDNo");
String StarLevel = a.get("StarLevel");
if(Data.hasValue(agentCode))
SQL.append(" and AgentCode=?");
if(Data.hasValue(name))
SQL.append(" and Name like ?");
if(Data.hasValue(a.get("ComCode")))
SQL.append(" and ComCode like ?");
if(Data.hasValue(openStatic))
SQL.append(" and OpenStatic=?");
if(Data.hasValue(agentStatic))
SQL.append(" and AgentStatic=?");
if(Data.hasValue(IDNo))
SQL.append(" and IDNo=?");
if(Data.hasValue(StarLevel))
SQL.append(" and StarLevel=?");
DBAccess d = new DBAccess();
//result = d.executeQuery(SQL.toString(),a.propList,pageSize,pageIndex);
result = d.pagination(SQL.toString(),a.propList,pageSize,pageIndex,"AgentCode");
setCOUNT(d.COUNT);
setEOF(d.EOF);
return result;
}
/**
* 查询优秀代理人(投保意向)使用 add by jll 2007-9-13
* @param comCode 管理机构代码
* @return List
*/
public List findExcellentAgent(String comCode){
String SQL = "SELECT a.agentnumber,a.agentname,a.agentcyclostyle from AgentUserInfo a left join Agent b"
+ " on b.AgentCode = a.AgentNumber"
+ " where AgentStatic='1'"
+ " and OpenStatic='1'"
+ " and ComCode like ? ";
List l = new ArrayList();
l.add(comCode + "%");
DBAccess DBA = new DBAccess();
return DBA.parseSQL(SQL,l);
}
/**
* 更新开通状态
* @param messageID 代理人号码
* @param status 状态
* @return boolean
*/
public boolean changeStatus(String messageID, String status) {
String newStatus = "";
List list = new ArrayList();
if("openStatic".equals(status)) {
newStatus = "openStatic=1";
}
else if("closeStatic".equals(status)) {
newStatus = "openStatic=0";
}
else if("agentOpen".equals(status)) {
newStatus = "agentStatic=1";
}
else if("agentClose".equals(status)) {
newStatus = "agentStatic=0";
}
try{
StringBuffer sql = new StringBuffer("Update Agent set " + newStatus + " where agentCode in(");
String[] messageIDArr = messageID.split(",");
for(int i = 0; i < messageIDArr.length; i++) {
sql.append("?,");
list.add(messageIDArr[i]);
}
sql.deleteCharAt(sql.lastIndexOf(","));
sql.append(")");
DBAccess d = new DBAccess();
return d.executeUpdate(sql.toString(),list);
}catch(Exception e){
e.printStackTrace();
System.out.println("changeStatus():" + e.getMessage());
return false;
}
}
/**
* 更新代理人
* @return boolean
*/
public boolean updateAgent(){
try{
StringBuffer sql = new StringBuffer("update Agent set ");
List l = new ArrayList();
for(int i=0;i<strList.size();i++){
Object[] strArray =(Object[]) strList.get(i);
sql.append(strArray[0]);
sql.append("=?,");
l.add(strArray[1]);
}
sql.deleteCharAt(sql.lastIndexOf(","));
sql.append(" where AgentCode=?");
l.add(this.get("AgentCode"));
strList.clear();
DBAccess q = new DBAccess();
return q.executeUpdate(sql.toString(),l);
}catch(Exception e){
e.printStackTrace();
System.out.println("Agent.update():" + e.getMessage());
return false;
}
}
/**
* 代理人验证
* @param userID 代理人号码
* @param inputPwd 代理人密码
* @param accountType 账号类型
* @return boolean
* @throws UserWrongException
*/
public boolean checkUser(String userID,String inputPwd, String accountType) throws UserWrongException {
if("agentCode".equals(accountType)) {
this.init(userID);
if(!Data.hasValue(this.get("Password")))
throw new UserWrongException("代理人编号不存在!");
if("0".equals(this.get("OpenStatic"))) {
throw new UserWrongException("用户已冻结!");
}
Md5 m = new Md5();
String encryptPwd = m.getMD5ofStr(inputPwd);
if(!encryptPwd.equalsIgnoreCase(this.get("Password"))){
throw new UserWrongException("密码不正确!");
}
}else if("IDNo".equals(accountType)) {
this.set("IDNo", userID);
String temp = this.findAgent(this, 1, 1);
this.init(temp);
if(!Data.hasValue(this.get("Password")))
throw new UserWrongException("身份证号码错误!");
if("0".equals(this.get("OpenStatic"))) {
throw new UserWrongException("用户已冻结!");
}
Md5 m = new Md5();
String encryptPwd = m.getMD5ofStr(inputPwd);
if(!encryptPwd.equalsIgnoreCase(this.get("Password"))){
throw new UserWrongException("密码不正确!");
}
}else{
throw new UserWrongException("用户名或密码不正确!");
}
return true;
}
/**
* 在此映射中关联指定值与指定键
* @param name 指定键
* @param value 指定值
*/
public void setUpdateValue(String name,Object value){
if(this.set(name,value)){
Object[] uValue = new Object[2];
uValue[0] = name;
uValue[1] = value;
strList.add(uValue);
}
}
/**
* 在此映射中关联指定值与指定键
* @param name 指定键
* @param value 指定值
*/
public boolean set(String name, Object value){
if(Property.contains(name)){
propList.put(name,value);
return true;
}else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -