📄 agent.java
字号:
return false;
}
/**
* 返回指定键在此映射中所映射的值
* @param name 指定键
* @return
*/
public String get(String name){
if (Property.contains(name)){
String value = (String)propList.get(name);
if(value != null && !value.equals(""))
return value;
else
return "";
}else
return "";
}
/**
* 返回COUNT
* @return int
*/
public int getCOUNT() {
return COUNT;
}
/**
* 设置COUNT
* @param count
*/
public void setCOUNT(int count) {
COUNT = count;
}
/**
* 返回EOF
* @return boolean
*/
public boolean isEOF() {
return EOF;
}
/**
* 设置EOF
* @param eof
*/
public void setEOF(boolean eof) {
EOF = eof;
}
/**
* 清空propList
*
*/
public void clear(){
propList.clear();
}
/**
* 返回开通状态
* @return
*/
public String getOpenStaticMsg() {
return openStaticMsg;
}
/**
* 设置开通状态
* @param openStaticMsg 开通状态
*/
public void setOpenStaticMsg(String openStaticMsg) {
this.openStaticMsg = openStaticMsg;
}
/**
* 批量更新密码
* @param Password 密码
* @param tmpID 代理人号码
* @return
*/
public boolean updatePW(String Password,String tmpID){
if(tmpID.endsWith(","))
tmpID = tmpID.substring(0,tmpID.length()-1);
String[] ID = tmpID.split(",");
if(ID.length<1)return false;
List list = new ArrayList();
list.add(Password);
String sql = "update Agent set Password=? where AgentCode in (";
for(int i=0;i<ID.length;i++){
if(Data.hasValue(ID[i])){
sql +="?,";
list.add(ID[i]);
}
}
sql = sql.substring(0,sql.length()-1);
sql += ")";
DBAccess db = new DBAccess();
return db.executeUpdate(sql, list);
}
/**
* 批量新增代理人
* @param excelUrl excel路径
* @return String
*/
public String BatchCreate(String excelUrl){
try{
Workbook workbook = Workbook.getWorkbook(new File(excelUrl));
Sheet sheet = workbook.getSheet(0);
int rows=sheet.getRows();//得到总行数
String showError="";
boolean CodeFlag;
boolean IDNoFlag;
Agent a = new Agent();
List l = new ArrayList();
//System.out.println("rows:"+rows);
for(int i=1;i<rows;i++){
CodeFlag=false;
IDNoFlag=false;
String[] colValue = new String[20];
colValue[0] = sheet.getCell(1,i).getContents().trim();
colValue[1] = sheet.getCell(2,i).getContents().trim();
colValue[2] = sheet.getCell(3,i).getContents().trim();
colValue[3] = sheet.getCell(4,i).getContents().trim();
colValue[4] = sheet.getCell(5,i).getContents().trim();
colValue[5] = sheet.getCell(6,i).getContents().trim();
colValue[6] = sheet.getCell(7,i).getContents().trim();
colValue[7] = sheet.getCell(8,i).getContents().trim();
colValue[8] = sheet.getCell(9,i).getContents().trim();
if(Data.hasValue(colValue[7]))
colValue[7] = Data.dateFormat(colValue[7],"yyyy-MM-dd");
colValue[9] = sheet.getCell(10,i).getContents().trim();
colValue[10] = sheet.getCell(11,i).getContents().trim();
colValue[11] = sheet.getCell(12,i).getContents().trim();
colValue[12] = sheet.getCell(13,i).getContents().trim();
System.out.println("kkkk:"+colValue[11]);
colValue[13] = sheet.getCell(14,i).getContents().trim();
colValue[14] = sheet.getCell(15,i).getContents().trim();
colValue[15] = sheet.getCell(16,i).getContents().trim();
colValue[16] = sheet.getCell(17,i).getContents().trim();
//colValue[17] = sheet.getCell(18,i).getContents();
//colValue[18] = sheet.getCell(19,i).getContents();
colValue[17] = sheet.getCell(20,i).getContents().trim();
colValue[18] = sheet.getCell(21,i).getContents().trim();
colValue[19] = sheet.getCell(22,i).getContents().trim();
//System.out.println(colValue[19]);
//查找库里是否存在
if(colValue[0]==null||"".equals(colValue[0]))
break;
a.clear();
//System.out.println(colValue[0]);
a.init(colValue[0]);
String id = a.get("AgentCode");
//System.out.println(id);
if(!(id==null||"".equals(id))){
CodeFlag=true; //在数据库中存在
}else{//查身份证
if (colValue[11].length()==15 || colValue[11].length()==18){
String pwd = colValue[11].substring(colValue[11].length()-6,colValue[11].length());
Md5 m = new Md5();
pwd = m.getMD5ofStr(pwd);
colValue[2] = pwd;
l.add(colValue);
}else{
IDNoFlag=true;
}
}
//System.out.println("CodeFlag:"+CodeFlag);
//System.out.println("IDNoFlag:"+IDNoFlag);
if(CodeFlag&&IDNoFlag){
//业务员号码 是否存在 是否身份证错误
showError+="<tr><td class='TableGrid'>"+colValue[0]+" </td><td class='TableGrid'>是 </td><td class='TableGrid'>是 </td></tr>\n";
//两个都错了
}else if(CodeFlag&&!IDNoFlag){
//库中存在Code
showError+="<tr><td class='TableGrid'>"+colValue[0]+" </td><td class='TableGrid'>是 </td><td class='TableGrid'> </td></tr>\n";
}else if(!CodeFlag&&IDNoFlag){
//身份证号错了
showError+="<tr><td class='TableGrid'>"+colValue[0]+" </td><td class='TableGrid'> </td><td class='TableGrid'>是 </td></tr>\n";
}
}
//System.out.println(l.size());
if("".equals(showError)){
if(updateBatchAdd(l))
return "addTrue";//更新数据成功
else
return "addFalse";//更新数据失败
}else
return showError;
}catch (Exception ex){
ex.printStackTrace();
return "";
}
}
/**
* 执行批量操作
* @param l 对象
* @return boolean
*/
public boolean updateBatchAdd(List l){
String sql = "INSERT into Agent values (?,?,?,?,?,?,?,to_date(?,'yyyy-MM-dd'),?,?,?,?,?,?,?,?,?,'','1','0',?,?,?,'0')";
DBAccess d = new DBAccess();
return d.mulExecute(sql,l);
}
/**
* 批量删除代理人
* @param excelUrl excel路径
* @return String
*/
public String BatchDelete(String excelUrl){
try{
Workbook workbook = Workbook.getWorkbook(new File(excelUrl));
Sheet sheet = workbook.getSheet(0);
int rows=sheet.getRows();//得到总行数
Agent a = new Agent();
List l = new ArrayList();
String showError="";
for(int i=1;i<rows;i++){
String[] colValue = new String[2];
colValue[0] = sheet.getCell(1,i).getContents().trim();//员工工号
colValue[1] = sheet.getCell(2,i).getContents().trim();//员工姓名
if(colValue[0]==null||"".equals(colValue[0]))
break;
a.clear();
a.init(colValue[0]);
String Name = a.get("Name")==null?"":a.get("Name").trim();
if(Name.equals(colValue[1])){
l.add(colValue);
}else if(Name.equals("")){//用户不存在
showError+="<tr><td class='TableGrid'>"+colValue[0]+" </td><td class='TableGrid'>是 </td><td class='TableGrid'> </td>";
}else{//用户名错误
showError+="<tr><td class='TableGrid'>"+colValue[0]+" </td><td class='TableGrid'> </td><td class='TableGrid'>是 </td>";
}
}
if(showError.equals("")){
if(deleteAgent(l)){
showError="deleteTrue";
}else{
showError="deleteFalse";
}
}
return showError;
}catch (Exception ex){
ex.printStackTrace();
return "";
}
}
/**
* 删除代理人
* @param l 对象
* @return boolean
*/
public boolean deleteAgent(List l){
String SQL = "DELETE from Agent WHERE AgentCode=? and name=?";
DBAccess d = new DBAccess();
return d.mulExecute(SQL,l);
}
public static void main(String[] args) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -