jlr提交
This commit is contained in:
154
src/main/java/com/dubh/common/dao/Dao.java
Normal file
154
src/main/java/com/dubh/common/dao/Dao.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.dubh.common.dao;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-15 上午11:19:21
|
||||
* 类说明 :公用方法接口类
|
||||
*/
|
||||
public interface Dao {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取单一对象
|
||||
* @param clazz 实体类
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
public Object getObject(Class clazz,Serializable id);
|
||||
|
||||
/**
|
||||
* 添加对象
|
||||
* @param object 实体类
|
||||
* @throws Exception
|
||||
*/
|
||||
public void saveObject(Object object) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新对象
|
||||
* @param object 实体对象
|
||||
* @throws Exception
|
||||
*/
|
||||
public void updateObject(Object object) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入hql语句进行批量更新对象
|
||||
* @param hqlStr HQL语句
|
||||
* @throws Exception
|
||||
*/
|
||||
public void updateHql(String hqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除对象
|
||||
* @param clazz 实体类
|
||||
* @param id 主键
|
||||
* @throws Exception
|
||||
*/
|
||||
public void removeObject(Class clazz, Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集
|
||||
* @param sqlStr SQL语句
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsBySql(String sqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集,并支持分页
|
||||
* @param sqlStr SQL语句
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页面大小
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsBySql(String sqlStr,int pageNo,int pageSize) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入hql语句获取记录集,并支持分页功能
|
||||
* @param hqlStr HQL语句
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页面大小
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsByHql(String hqlStr,int pageNo,int pageSize) throws Exception;
|
||||
|
||||
/**
|
||||
* 批量删除数据
|
||||
* @param hqlStr HQL语句
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteHql(String hqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入hql语句获取记录集
|
||||
* @param hqlStr HQL语句
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsByHql(String hqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集行数
|
||||
* @param sqlStr SQL语句
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsBySql(String sqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过传入标准hql语句获取记录集行数
|
||||
* @param hqlStr HQL语句
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsByHql(String hqlStr) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param object 实体对象
|
||||
*/
|
||||
public void deleteObject(Object object) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存或更新一个实体对象
|
||||
* @param object 实体对象
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
public void saveOrUpdate(Object object) throws Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 标准SQL语句修改数据
|
||||
* @param sql
|
||||
* @throws Exception
|
||||
* */
|
||||
public void updateSql (String sql) throws Exception;
|
||||
/**
|
||||
* 调用存储过程信息
|
||||
* @param stroName
|
||||
* @throws Exception
|
||||
*/
|
||||
public void getcallStor(String stroName,String parm) throws Exception;
|
||||
|
||||
/**
|
||||
* 执行标准SQL语句
|
||||
* @param sql
|
||||
* @throws Exception
|
||||
* */
|
||||
public void createView(String sql) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 获取单一对象
|
||||
* @param hql
|
||||
* @return Object
|
||||
* @throws Exception
|
||||
* */
|
||||
public Object getObjectHql(String hql) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
package com.dubh.common.dao.hibernate;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import org.hibernate.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.orm.ObjectRetrievalFailureException;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-15 上午11:20:08 类说明:公用方法实现类
|
||||
*/
|
||||
public class BaseDaoHibernate implements Dao {
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
/*public void setSessionFactory(SessionFactory sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 添加对象
|
||||
*
|
||||
* @param object
|
||||
* 实体类
|
||||
* @throws Exception
|
||||
*/
|
||||
public void saveObject(Object object) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx=null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
String entityName = getEntityName(object);
|
||||
session.save(entityName, object);
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("saveObject:" + ex);
|
||||
} finally {
|
||||
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
public SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新对象
|
||||
*
|
||||
* @param object
|
||||
* 实体对象
|
||||
* @throws Exception
|
||||
*/
|
||||
public void updateObject(Object object) throws Exception {
|
||||
|
||||
Session session = null;
|
||||
Transaction tx=null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
String entityName = getEntityName(object);
|
||||
session.update(entityName, object);
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("updateObject:" + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对象
|
||||
*
|
||||
* @param clazz
|
||||
* 实体类
|
||||
* @param id
|
||||
* 主键
|
||||
* @throws Exception
|
||||
*/
|
||||
public void removeObject(Class clazz, Serializable id) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try{
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
session.delete(getObject(clazz, id));
|
||||
tx.commit();
|
||||
}catch(Exception ex){
|
||||
if(null !=tx){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("removeObject:" + ex);
|
||||
}finally{
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入hql语句进行批量更新对象
|
||||
*
|
||||
* @param hqlStr
|
||||
* HQL语句
|
||||
* @throws Exception
|
||||
*/
|
||||
public void updateHql(String hqlStr) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
tx = session.beginTransaction();
|
||||
Query query = session.createQuery(hqlStr);
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("updateObjects" + ex);
|
||||
} finally {
|
||||
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单一对象
|
||||
*
|
||||
* @param clazz
|
||||
* 实体类
|
||||
* @param id
|
||||
* 主键
|
||||
* @return
|
||||
*/
|
||||
public Object getObject(Class clazz, Serializable id) {
|
||||
Object o = sessionFactory.getCurrentSession().get(clazz, id);
|
||||
|
||||
if (o == null) {
|
||||
throw new ObjectRetrievalFailureException(clazz, id);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入hql语句获取记录集,并支持分页功能
|
||||
*
|
||||
* @param hqlStr
|
||||
* HQL语句
|
||||
* @param pageNo
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 页面大小
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsByHql(String hqlStr, int pageNo, int pageSize)
|
||||
throws Exception {
|
||||
List list = new ArrayList();
|
||||
Session session = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
Query query = session.createQuery(hqlStr);
|
||||
query.setFirstResult(getFirstSize(pageNo, pageSize));
|
||||
query.setMaxResults(pageSize);
|
||||
list = query.list();
|
||||
System.out.println(list);
|
||||
return list;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsByHql" + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集
|
||||
*
|
||||
* @param sqlStr
|
||||
* SQL语句
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsBySql(String sqlStr) throws Exception {
|
||||
Session session = null;
|
||||
try {
|
||||
long startTime=System.currentTimeMillis();
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
SQLQuery sqlQuery = session.createSQLQuery(sqlStr);
|
||||
System.out.println("getRsBySql1:"+(System.currentTimeMillis()-startTime));
|
||||
List list=sqlQuery.list();
|
||||
System.out.println("getRsBySql2:"+(System.currentTimeMillis()-startTime));
|
||||
return list;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsBySql: " + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集,并支持分页
|
||||
*
|
||||
* @param sqlStr
|
||||
* SQL语句
|
||||
* @param pageNo
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 页面大小
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsBySql(String sqlStr, int pageNo, int pageSize)
|
||||
throws Exception {
|
||||
Session session = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
SQLQuery sqlQuery = session.createSQLQuery(sqlStr);
|
||||
// sqlQuery.list().size();
|
||||
sqlQuery.setFirstResult(getFirstSize(pageNo, pageSize));
|
||||
sqlQuery.setMaxResults(pageSize);
|
||||
return sqlQuery.list();
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsBySql: " + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集行数
|
||||
*
|
||||
* @param sqlStr
|
||||
* SQL语句
|
||||
* @return 返回记录集数量
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsBySql(String sqlStr) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Session session = null;
|
||||
Integer count = new Integer(0);
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
SQLQuery sqlQuery = session.createSQLQuery(sqlStr);
|
||||
List list = sqlQuery.list();
|
||||
if (null != list && list.size() > 0) {
|
||||
count = list.size();
|
||||
}
|
||||
return count;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsCountsBySql: " + ex);
|
||||
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通过传入标准hql语句获取记录集行数
|
||||
*
|
||||
* @param hqlStr
|
||||
* SQL语句
|
||||
* @return 返回记录集数量
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsBySelectHql(String hqlStr) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Session session = null;
|
||||
Integer count = new Integer(0);
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
String countsql="select count(*)"+hqlStr.substring(hqlStr.toLowerCase().indexOf("from"));
|
||||
|
||||
//createSQLQuery和createQuery
|
||||
count = Integer.valueOf(session.createQuery(countsql).uniqueResult().toString());
|
||||
|
||||
return count;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsCountsBySql: " + ex);
|
||||
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取记录集行数
|
||||
*
|
||||
* @param sqlStr
|
||||
* SQL语句
|
||||
* @return 返回记录集数量
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsBySelectSql(String sqlStr) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Session session = null;
|
||||
Integer count = new Integer(0);
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
// String countsql="select count(*)"+sqlStr.substring(sqlStr.toLowerCase().indexOf("from"));
|
||||
String countsql="select count(*)"+sqlStr.substring(sqlStr.toLowerCase().lastIndexOf("from"));
|
||||
//createSQLQuery和createQuery
|
||||
count = Integer.valueOf(session.createSQLQuery(countsql).uniqueResult().toString());
|
||||
|
||||
return count;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsCountsBySql: " + ex);
|
||||
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入标准sql语句获取单个sql执行语句
|
||||
*
|
||||
* @param sqlStr
|
||||
* SQL语句
|
||||
* @return 返回记录集数量
|
||||
* @throws Exception
|
||||
*/
|
||||
public Double getRsSingleCountsBySelectSql(String sqlStr) throws Exception {
|
||||
Session session = null;
|
||||
Double count = new Double(0);
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
String countsql=sqlStr;
|
||||
|
||||
count = Double.valueOf((session.createSQLQuery(countsql).uniqueResult()).toString());
|
||||
|
||||
return count;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsCountsBySql: " + ex);
|
||||
|
||||
}catch (NullPointerException ex) {
|
||||
ex.printStackTrace();
|
||||
return 0.0;
|
||||
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通过传入标准hql语句获取记录集行数
|
||||
*
|
||||
* @param hqlStr
|
||||
* HQL语句
|
||||
* @throws Exception
|
||||
*/
|
||||
public Integer getRsCountsByHql(String hqlStr) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Session session = null;
|
||||
Integer count = new Integer(0);
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
Query query = session.createQuery(hqlStr);
|
||||
List list = query.list();
|
||||
if (null != list && list.size() > 0) {
|
||||
count = list.size();
|
||||
}
|
||||
return count;
|
||||
} catch (HibernateException ex) {
|
||||
throw new RuntimeException("getRsCountsByHql:" + ex);
|
||||
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过传入hql语句获取记录集
|
||||
*
|
||||
* @param hqlStr
|
||||
* HQL语句
|
||||
* @return 返回记录集
|
||||
* @throws Exception
|
||||
*/
|
||||
public List getRsByHql(String hqlStr) throws Exception {
|
||||
Query query = sessionFactory.getCurrentSession().createQuery(hqlStr);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除数据
|
||||
*
|
||||
* @param hqlStr
|
||||
* HQL语句
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteHql(String hqlStr) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
tx = session.beginTransaction();
|
||||
Query query = session.createQuery(hqlStr);
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("deleteHql:" + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param object
|
||||
* 实体对象
|
||||
*/
|
||||
public void deleteObject(Object object) throws Exception {
|
||||
Session session =null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
session.delete(object);
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("deleteObject:" + e);
|
||||
}finally{
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭资源
|
||||
*
|
||||
* @param object
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void closeResouce(Object object) throws Exception {
|
||||
if (null == object)
|
||||
return;
|
||||
|
||||
if (object instanceof Connection) {
|
||||
Connection conn = (Connection) object;
|
||||
conn.close();
|
||||
} else if (object instanceof Statement) {
|
||||
Statement statement = (Statement) object;
|
||||
statement.close();
|
||||
} else if (object instanceof PreparedStatement) {
|
||||
PreparedStatement prepared = (PreparedStatement) object;
|
||||
prepared.close();
|
||||
} else if (object instanceof ResultSet) {
|
||||
ResultSet rs = (ResultSet) object;
|
||||
rs.close();
|
||||
} else if (object instanceof Session) {
|
||||
Session session = (Session) object;
|
||||
session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得实体对象名称
|
||||
*
|
||||
* @param object
|
||||
* 实体对象
|
||||
* @return
|
||||
*/
|
||||
private String getEntityName(Object object) {
|
||||
String entityName = new String("");
|
||||
try {
|
||||
Class objectClass = object.getClass();
|
||||
entityName = objectClass.getName();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("" + ex);
|
||||
}
|
||||
return entityName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或更新一个实体对象
|
||||
*
|
||||
* @param object
|
||||
* 实体对象
|
||||
* @throws Exception
|
||||
* 异常信息
|
||||
*/
|
||||
public void saveOrUpdate(Object object) throws Exception {
|
||||
Session session =null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
session.saveOrUpdate(object);
|
||||
session.flush();
|
||||
session.clear();
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("saveOrUpdate " + e);
|
||||
}finally{
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前分页开始的记录数
|
||||
*
|
||||
* @param pageNo
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 页面大小
|
||||
* @return 当前分页开始记录数
|
||||
*/
|
||||
private int getFirstSize(int pageNo, int pageSize) {
|
||||
int firstSize = 0;
|
||||
firstSize = (pageNo - 1) * pageSize;
|
||||
return firstSize;
|
||||
}
|
||||
|
||||
public void updateSql(String sql) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = getSession();
|
||||
tx = session.beginTransaction();
|
||||
SQLQuery query = session.createSQLQuery(sql);
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("updateSql:" + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用存储过程信息
|
||||
*
|
||||
* @param stroName
|
||||
* @throws Exception
|
||||
*/
|
||||
public void getcallStor(String stroName, String parm) throws Exception {
|
||||
Session session = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
String proc = "{ call " + stroName + "(:param) }";
|
||||
SQLQuery query = session.createSQLQuery(proc);
|
||||
if (null != parm && !"".equals(parm)) {
|
||||
query.setParameter("param", parm);
|
||||
}
|
||||
query.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
|
||||
throw new RuntimeException("getcallStor:" + ex);
|
||||
|
||||
} finally {
|
||||
|
||||
closeResouce(session);
|
||||
}
|
||||
}
|
||||
|
||||
public void createView(String sqlStr) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
tx = session.beginTransaction();
|
||||
SQLQuery query = sessionFactory.getCurrentSession().createSQLQuery(
|
||||
sqlStr);
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("createView:" + ex);
|
||||
|
||||
} finally {
|
||||
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void deletes(String hqlStr) throws Exception {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
tx = session.beginTransaction();
|
||||
Query query = session.createQuery(hqlStr);
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
} catch (Exception ex) {
|
||||
if(tx !=null){
|
||||
tx.rollback();
|
||||
}
|
||||
throw new RuntimeException("deletes:" + ex);
|
||||
|
||||
} finally {
|
||||
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObjectHql(String hql) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Session session = null;
|
||||
Object obj = null;
|
||||
try {
|
||||
session = sessionFactory.getCurrentSession().getSessionFactory()
|
||||
.openSession();
|
||||
Query query = session.createQuery(hql);
|
||||
obj = query.uniqueResult();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("getObjectHql:" + ex);
|
||||
} finally {
|
||||
closeResouce(session);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
public Session getSession() {
|
||||
Session session = null;
|
||||
if(null==session || false==session.isOpen()){
|
||||
session = sessionFactory.openSession();
|
||||
}else{
|
||||
session=sessionFactory.getCurrentSession();
|
||||
}
|
||||
return session;
|
||||
}
|
||||
}
|
||||
31
src/main/java/com/dubh/common/dto/BaseDto.java
Normal file
31
src/main/java/com/dubh/common/dto/BaseDto.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.dubh.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-15 上午11:23:33
|
||||
* 类说明 实体类序列化及分页参数封装
|
||||
*/
|
||||
public class BaseDto implements Serializable {
|
||||
protected int pageNo = 0;
|
||||
protected int pageSize =0;
|
||||
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public void setPageNo(int pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
60
src/main/java/com/dubh/common/file/Downfile.java
Normal file
60
src/main/java/com/dubh/common/file/Downfile.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.dubh.common.file;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-8-12 下午7:17:21
|
||||
* 类说明
|
||||
*/
|
||||
public class Downfile {
|
||||
|
||||
public static void DownloadFile(HttpServletRequest request,HttpServletResponse response,String filename){
|
||||
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
|
||||
String path = request.getSession().getServletContext().getRealPath("attached")+File.separator+filename;
|
||||
File file = null;
|
||||
try {
|
||||
file = new File(path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(null!=file){
|
||||
if(file.exists()){
|
||||
try {
|
||||
//弹出下载对话框
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "utf-8"));
|
||||
OutputStream os = os=response.getOutputStream();
|
||||
InputStream is= is=new FileInputStream(file);
|
||||
BufferedInputStream bis=new BufferedInputStream(is);
|
||||
BufferedOutputStream bos= new BufferedOutputStream(os);
|
||||
//用输入流进行先读,然后用输出流去写
|
||||
int bytesRead = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
while ((bytesRead = bis.read(buffer, 0, 8192)) != -1) {
|
||||
bos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
os.flush();
|
||||
os.close();
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
243
src/main/java/com/dubh/common/file/UploadFile.java
Normal file
243
src/main/java/com/dubh/common/file/UploadFile.java
Normal file
@@ -0,0 +1,243 @@
|
||||
package com.dubh.common.file;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-18 下午8:29:45
|
||||
*
|
||||
* 类说明 :文件上传
|
||||
*/
|
||||
public class UploadFile {
|
||||
|
||||
|
||||
/**
|
||||
* 多文件上传
|
||||
* @param HttpServletRequest
|
||||
* @param HttpServletResponse
|
||||
* @return JSONArray
|
||||
* */
|
||||
public static JSONArray uploadmore(HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
JSONArray array = new JSONArray();
|
||||
try {
|
||||
// 创建一个通用的多部分解析器
|
||||
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
|
||||
request.getSession().getServletContext());
|
||||
// 判断 request 是否有文件上传,即多部分请求
|
||||
if (multipartResolver.isMultipart(request)) {
|
||||
// 转换成多部分request
|
||||
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
|
||||
// 取得request中的所有文件名
|
||||
Iterator<String> iter = multiRequest.getFileNames();
|
||||
while (iter.hasNext()) {
|
||||
JSONObject object = new JSONObject();
|
||||
// 记录上传过程起始时的时间,用来计算上传时间
|
||||
int pre = (int) System.currentTimeMillis();
|
||||
// 取得上传文件
|
||||
MultipartFile file = multiRequest.getFile(iter.next());
|
||||
if (file != null) {
|
||||
// 取得当前上传文件的文件名称
|
||||
String myFileName = file.getOriginalFilename();
|
||||
// 如果名称不为“”,说明该文件存在,否则说明该文件不存在
|
||||
if (myFileName.trim() != "") {
|
||||
String oldname = myFileName;
|
||||
object.put("filename",oldname);
|
||||
object.put("filekj", file.getName());
|
||||
//定义上传路径命名新文件夹
|
||||
String mkfile = RequestUtil.getid(0);
|
||||
//判断新文件夹是否存在
|
||||
String paths = request.getSession().getServletContext().getRealPath("attached")+"/"+mkfile;
|
||||
File newfile = new File(paths);
|
||||
if(!newfile.exists()){
|
||||
newfile.mkdir();
|
||||
}
|
||||
//新文件名称
|
||||
String newfilename=RequestUtil.getid(3)+"."+RequestUtil.getExtensionName(myFileName);
|
||||
//文件绝对路径
|
||||
String path = paths+"/"+ newfilename;
|
||||
File localFile = new File(path);
|
||||
file.transferTo(localFile);
|
||||
//文件相对路径
|
||||
String filepath = "/"+"attached"+"/"+mkfile+"/"+newfilename;
|
||||
object.put("filepath",filepath);
|
||||
// 记录上传该文件后的时间
|
||||
int finaltime = (int) System.currentTimeMillis();
|
||||
int time = finaltime - pre;
|
||||
object.put("time",time);
|
||||
array.put(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 单文件上传
|
||||
* @param HttpServletRequest
|
||||
* @param HttpServletResponse
|
||||
* @return JSONObject
|
||||
* */
|
||||
public static JSONObject uploadone(HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
JSONObject object = new JSONObject();
|
||||
String oldname ="";
|
||||
String filepath="";
|
||||
int time =0;
|
||||
try {
|
||||
// 创建一个通用的多部分解析器
|
||||
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
|
||||
request.getSession().getServletContext());
|
||||
// 判断 request 是否有文件上传,即多部分请求
|
||||
if (multipartResolver.isMultipart(request)) {
|
||||
// 转换成多部分request
|
||||
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
|
||||
// 取得request中的所有文件名
|
||||
Iterator<String> iter = multiRequest.getFileNames();
|
||||
while (iter.hasNext()) {
|
||||
// 记录上传过程起始时的时间,用来计算上传时间
|
||||
int pre = (int) System.currentTimeMillis();
|
||||
// 取得上传文件
|
||||
MultipartFile file = multiRequest.getFile(iter.next());
|
||||
if (file != null) {
|
||||
// 取得当前上传文件的文件名称
|
||||
String myFileName = file.getOriginalFilename();
|
||||
// 如果名称不为“”,说明该文件存在,否则说明该文件不存在
|
||||
if (myFileName.trim() != "") {
|
||||
oldname = myFileName;
|
||||
|
||||
//定义上传路径命名新文件夹
|
||||
String mkfile = RequestUtil.getid(5);
|
||||
//判断新文件夹是否存在
|
||||
String paths = request.getSession().getServletContext().getRealPath("attached")+"/"+mkfile;
|
||||
File newfile = new File(paths);
|
||||
if(!newfile.exists()){
|
||||
newfile.mkdir();
|
||||
}
|
||||
//新文件名称
|
||||
String newfilename=RequestUtil.getid(3)+"."+RequestUtil.getExtensionName(myFileName);
|
||||
//文件绝对路径
|
||||
String path = paths+"/"+ newfilename;
|
||||
File localFile = new File(path);
|
||||
file.transferTo(localFile);
|
||||
//文件相对路径
|
||||
filepath = "/"+"attached"+"/"+mkfile+"/"+newfilename;
|
||||
|
||||
}
|
||||
}
|
||||
// 记录上传该文件后的时间
|
||||
int finaltime = (int) System.currentTimeMillis();
|
||||
time = finaltime - pre;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
object.put("time",time);
|
||||
object.put("filename",oldname);
|
||||
object.put("filepath",filepath);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 多文件上传(仅供与检测端使用)
|
||||
* @param HttpServletRequest
|
||||
* @param HttpServletResponse
|
||||
* @return JSONArray
|
||||
* */
|
||||
public static JSONArray uploadmore2(HttpServletRequest request,
|
||||
HttpServletResponse response,String id) {
|
||||
JSONArray array = new JSONArray();
|
||||
try {
|
||||
// 创建一个通用的多部分解析器
|
||||
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
|
||||
// 判断 request 是否有文件上传,即多部分请求
|
||||
if (multipartResolver.isMultipart(request)) {
|
||||
// 转换成多部分request
|
||||
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
|
||||
// 取得request中的所有文件名
|
||||
Iterator<String> iter = multiRequest.getFileNames();
|
||||
while (iter.hasNext()) {
|
||||
JSONObject object = new JSONObject();
|
||||
// 记录上传过程起始时的时间,用来计算上传时间
|
||||
int pre = (int) System.currentTimeMillis();
|
||||
// 取得上传文件
|
||||
MultipartFile file = multiRequest.getFile(iter.next());
|
||||
synchronized (file) {
|
||||
if (file != null) {
|
||||
// 取得当前上传文件的文件名称
|
||||
String myFileName = file.getOriginalFilename();
|
||||
// 如果名称不为“”,说明该文件存在,否则说明该文件不存在
|
||||
if (myFileName.trim() != "") {
|
||||
String oldname = myFileName;
|
||||
oldname=oldname.replaceAll("_", "");
|
||||
object.put("filename",oldname);
|
||||
object.put("filekj", file.getName());
|
||||
object.put("filesize", file.getSize()/1024);
|
||||
String type=oldname.substring((oldname.lastIndexOf(".")+1),oldname.length());
|
||||
object.put("type", type);
|
||||
//定义上传路径命名新文件夹
|
||||
String mkfile =id;
|
||||
//判断新文件夹是否存在
|
||||
String paths = request.getSession().getServletContext().getRealPath("attached")+"/"+mkfile;
|
||||
File newfile = new File(paths);
|
||||
if(!newfile.exists()){
|
||||
newfile.mkdir();
|
||||
}
|
||||
//新文件名称
|
||||
// String newfilename=RequestUtil.getid(3)+"."+RequestUtil.getExtensionName(myFileName);
|
||||
String newfilename=UUID.randomUUID()+"."+RequestUtil.getExtensionName(myFileName);
|
||||
//文件绝对路径
|
||||
// String path = paths+"/"+ oldname;
|
||||
String path = paths+"/"+ newfilename;
|
||||
File localFile = new File(path);
|
||||
file.transferTo(localFile);
|
||||
//文件相对路径
|
||||
// String filepath = "/"+"attached"+"/"+mkfile+"/"+oldname;
|
||||
String filepath = "/"+"attached"+"/"+mkfile+"/"+newfilename;
|
||||
object.put("filepath",filepath);
|
||||
// 记录上传该文件后的时间
|
||||
int finaltime = (int) System.currentTimeMillis();
|
||||
int time = finaltime - pre;
|
||||
System.out.println(file.getName()+":"+filepath);
|
||||
object.put("time",time);
|
||||
array.put(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
}
|
||||
21
src/main/java/com/dubh/sysconfig/EacheConfig.java
Normal file
21
src/main/java/com/dubh/sysconfig/EacheConfig.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.dubh.sysconfig;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-8-14 上午9:04:13
|
||||
* 类说明
|
||||
*/
|
||||
public class EacheConfig {
|
||||
//当前方法名
|
||||
public static final String methodnames = "#root.methodName";
|
||||
//当前方法
|
||||
public static final String methodname = "#root.method.name";
|
||||
//当前被调用的对象
|
||||
public static final String targetobject = "#root.target";
|
||||
//当前被调用的对象的class
|
||||
public static final String targetclass = "#root.targetClass";
|
||||
//当前方法参数组成的数组
|
||||
public static final String args = "#root.args[0]";
|
||||
//当前被调用的方法使用的Cache
|
||||
public static final String caches = "#root.caches[0].name";
|
||||
|
||||
}
|
||||
69
src/main/java/com/dubh/sysconfig/ehcache.xml
Normal file
69
src/main/java/com/dubh/sysconfig/ehcache.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Ehcache2.x的变化(取自https://github.com/springside/springside4/wiki/Ehcache) -->
|
||||
<!-- 1)最好在ehcache.xml中声明不进行updateCheck -->
|
||||
<!-- 2)为了配合BigMemory和Size Limit,原来的属性最好改名 -->
|
||||
<!-- maxElementsInMemory->maxEntriesLocalHeap -->
|
||||
<!-- maxElementsOnDisk->maxEntriesLocalDisk -->
|
||||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
|
||||
updateCheck="false">
|
||||
<diskStore path="java.io.tmpdir"/>
|
||||
<cache name="serviceCache"
|
||||
eternal="false"
|
||||
maxElementsOnDisk="0"
|
||||
maxElementsInMemory="10000000"
|
||||
overflowToDisk="false"
|
||||
diskPersistent="false"
|
||||
timeToIdleSeconds="0"
|
||||
timeToLiveSeconds="0"
|
||||
memoryStoreEvictionPolicy="LRU" />
|
||||
|
||||
<cache name="testCache"
|
||||
eternal="false"
|
||||
maxElementsInMemory="100"
|
||||
overflowToDisk="false"
|
||||
diskPersistent="false"
|
||||
timeToIdleSeconds="0"
|
||||
timeToLiveSeconds="300"
|
||||
memoryStoreEvictionPolicy="LRU" />
|
||||
</ehcache>
|
||||
<!-- <ehcache>
|
||||
<diskStore path="java.io.tmpdir"/>
|
||||
<defaultCache
|
||||
maxElementsInMemory="1000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="30000"
|
||||
timeToLiveSeconds="60000"
|
||||
overflowToDisk="false"/>
|
||||
<cache name="serviceCache"
|
||||
maxElementsOnDisk="0"
|
||||
maxElementsInMemory="200000"
|
||||
eternal="true"
|
||||
overflowToDisk="false"
|
||||
diskPersistent="true"
|
||||
memoryStoreEvictionPolicy="LFU"/>
|
||||
</ehcache> -->
|
||||
<!--
|
||||
<diskStore>==========当内存缓存中对象数量超过maxElementsInMemory时,将缓存对象写到磁盘缓存中(需对象实现序列化接口)
|
||||
<diskStore path="">==用来配置磁盘缓存使用的物理路径,Ehcache磁盘缓存使用的文件后缀名是*.data和*.index
|
||||
name=================缓存名称,cache的唯一标识(ehcache会把这个cache放到HashMap里)
|
||||
maxElementsOnDisk====磁盘缓存中最多可以存放的元素数量,0表示无穷大
|
||||
maxElementsInMemory==内存缓存中最多可以存放的元素数量,若放入Cache中的元素超过这个数值,则有以下两种情况
|
||||
1)若overflowToDisk=true,则会将Cache中多出的元素放入磁盘文件中
|
||||
2)若overflowToDisk=false,则根据memoryStoreEvictionPolicy策略替换Cache中原有的元素
|
||||
eternal==============缓存中对象是否永久有效,即是否永驻内存,true时将忽略timeToIdleSeconds和timeToLiveSeconds
|
||||
timeToIdleSeconds====缓存数据在失效前的允许闲置时间(单位:秒),仅当eternal=false时使用,默认值是0表示可闲置时间无穷大,此为可选属性
|
||||
即访问这个cache中元素的最大间隔时间,若超过这个时间没有访问此Cache中的某个元素,那么此元素将被从Cache中清除
|
||||
timeToLiveSeconds====缓存数据在失效前的允许存活时间(单位:秒),仅当eternal=false时使用,默认值是0表示可存活时间无穷大
|
||||
即Cache中的某元素从创建到清楚的生存时间,也就是说从创建开始计时,当超过这个时间时,此元素将从Cache中清除
|
||||
overflowToDisk=======内存不足时,是否启用磁盘缓存(即内存中对象数量达到maxElementsInMemory时,Ehcache会将对象写到磁盘中)
|
||||
会根据标签中path值查找对应的属性值,写入磁盘的文件会放在path文件夹下,文件的名称是cache的名称,后缀名是data
|
||||
diskPersistent=======是否持久化磁盘缓存,当这个属性的值为true时,系统在初始化时会在磁盘中查找文件名为cache名称,后缀名为index的文件
|
||||
这个文件中存放了已经持久化在磁盘中的cache的index,找到后会把cache加载到内存
|
||||
要想把cache真正持久化到磁盘,写程序时注意执行net.sf.ehcache.Cache.put(Element element)后要调用flush()方法
|
||||
diskExpiryThreadIntervalSeconds==磁盘缓存的清理线程运行间隔,默认是120秒
|
||||
diskSpoolBufferSizeMB============设置DiskStore(磁盘缓存)的缓存区大小,默认是30MB
|
||||
memoryStoreEvictionPolicy========内存存储与释放策略,即达到maxElementsInMemory限制时,Ehcache会根据指定策略清理内存
|
||||
共有三种策略,分别为LRU(最近最少使用)、LFU(最常用的)、FIFO(先进先出)
|
||||
-->
|
||||
|
||||
3
src/main/java/com/dubh/sysconfig/group.properties
Normal file
3
src/main/java/com/dubh/sysconfig/group.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
functiontype=user
|
||||
initpassword=111111
|
||||
userexportcoll=\u90E8\u95E8\u540D\u79F0,\u7528\u6237\u59D3\u540D,\u7528\u6237\u5E10\u53F7,\u6027\u522B,\u8054\u7CFB\u7535\u8BDD,\u90AE\u7BB1,\u7528\u6237\u804C\u79F0,\u6BD5\u4E1A\u9662\u6821,\u7C4D\u8D2F,\u6C11\u65CF,\u8EAB\u4EFD\u8BC1\u53F7\u7801,\u6237\u7C4D\u5730\u5740,\u5C45\u4F4F\u5730\u5740,\u7528\u6237\u63CF\u8FF0
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.dubh.syslog.annotation;
|
||||
import java.lang.annotation.*;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-18 下午12:43:33
|
||||
* 类说明 :自定义注解 后置通知拦截Controller
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SystemControllerAfterLog {
|
||||
|
||||
String description() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.dubh.syslog.annotation;
|
||||
import java.lang.annotation.*;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-18 下午12:43:33
|
||||
* 类说明 :自定义注解 前置通知拦截Controller
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SystemControllerBeforeLog {
|
||||
|
||||
String description() default "";
|
||||
|
||||
}
|
||||
|
||||
263
src/main/java/com/dubh/syslog/annotation/SystemLogAspect.java
Normal file
263
src/main/java/com/dubh/syslog/annotation/SystemLogAspect.java
Normal file
@@ -0,0 +1,263 @@
|
||||
package com.dubh.syslog.annotation;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-18 下午12:46:28 类说明:切入点
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class SystemLogAspect {
|
||||
// 注入Service用于把日志保存数据库
|
||||
// @Resource(name = "syslogservice")
|
||||
// private SyslogService syslogservice;
|
||||
|
||||
// Service层切点
|
||||
@Pointcut("@annotation(com.dubh.syslog.annotation.SystemServiceLog)")
|
||||
public void serviceAspect() {
|
||||
}
|
||||
|
||||
// 前置Controller层切点
|
||||
@Pointcut("@annotation(com.dubh.syslog.annotation.SystemControllerBeforeLog)")
|
||||
public void controllerBeforeAspect() {
|
||||
}
|
||||
|
||||
// 后置Controller层切点
|
||||
@Pointcut("@annotation(com.dubh.syslog.annotation.SystemControllerAfterLog)")
|
||||
public void controllerAfterAspect() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置通知 用于拦截Controller层记录用户的操作
|
||||
*
|
||||
* @param joinPoint
|
||||
* 切点
|
||||
*/
|
||||
@Before("controllerBeforeAspect()")
|
||||
public void doBefore(JoinPoint joinPoint) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
||||
.getRequestAttributes()).getRequest();
|
||||
// // 读取session中的用户
|
||||
// Tblsysuser user = SessionUser.getsession(request);
|
||||
// String loginname = "";
|
||||
// String loginkey = "";
|
||||
// String loginaccount = "";
|
||||
// if (null != user) {
|
||||
// loginname = user.getSysusername();
|
||||
// loginkey = user.getSysuserkey();
|
||||
// loginaccount = user.getSysaccount();
|
||||
// }
|
||||
// // 请求的IP
|
||||
// String ip = RequestUtil.getIpAddr(request);
|
||||
// try {
|
||||
// Tblsyslog loginfo = new Tblsyslog();
|
||||
// loginfo.setSyslogkey(RequestUtil.getid(6));
|
||||
// loginfo.setSysuserkey(loginkey);
|
||||
// loginfo.setSysuseraccount(loginaccount);
|
||||
// loginfo.setSysusername(loginname);
|
||||
// loginfo.setSyspagename(joinPoint.getTarget().getClass().getName()
|
||||
// + "." + joinPoint.getSignature().getName());
|
||||
// loginfo.setSysclassnameen(joinPoint.getTarget().getClass()
|
||||
// .getName());
|
||||
// loginfo.setSyslogmothoden(joinPoint.getSignature().getName());
|
||||
// loginfo.setSyslogmothodcn(getControllerBeforeMethodDescription(joinPoint));
|
||||
// loginfo.setSysipaddress(ip);
|
||||
// loginfo.setSyslogdate(RequestUtil.getDateTime());
|
||||
//// syslogservice.savelog(loginfo);
|
||||
// } catch (Exception e) {
|
||||
// // 记录本地异常日志
|
||||
// System.out.println("==前置通知异常==");
|
||||
// System.out.println("异常信息:{}" + e.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 后置通知 用于拦截Controller层记录用户的操作
|
||||
*
|
||||
* @param joinPoint
|
||||
* 切点
|
||||
*/
|
||||
@After("controllerAfterAspect()")
|
||||
public void doAfter(JoinPoint joinPoint) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
||||
.getRequestAttributes()).getRequest();
|
||||
// 读取session中的用户
|
||||
// Tblsysuser user = SessionUser.getsession(request);
|
||||
// String loginname = "";
|
||||
// String loginaccount = "";
|
||||
// String loginkey ="";
|
||||
// if(null !=user){
|
||||
// loginname = user.getSysusername();
|
||||
// loginaccount = user.getSysaccount();
|
||||
// loginkey = user.getSysuserkey();
|
||||
// }
|
||||
// // 请求的IP
|
||||
// String ip = RequestUtil.getIpAddr(request);
|
||||
// try {
|
||||
// Tblsyslog loginfo = new Tblsyslog();
|
||||
// loginfo.setSyslogkey(RequestUtil.getid(6));
|
||||
// loginfo.setSysuserkey(loginkey);
|
||||
// loginfo.setSysuseraccount(loginaccount);
|
||||
// loginfo.setSysusername(loginname);
|
||||
// loginfo.setSyspagename(joinPoint.getTarget().getClass().getName()
|
||||
// + "." + joinPoint.getSignature().getName());
|
||||
// loginfo.setSysclassnameen(joinPoint.getTarget().getClass()
|
||||
// .getName());
|
||||
// loginfo.setSyslogmothoden(joinPoint.getSignature().getName());
|
||||
// loginfo.setSyslogmothodcn(getControllerAfterMethodDescription(joinPoint));
|
||||
// loginfo.setSysipaddress(ip);
|
||||
// loginfo.setSyslogdate(RequestUtil.getDateTime());
|
||||
//// syslogservice.savelog(loginfo);
|
||||
// } catch (Exception e) {
|
||||
// // 记录本地异常日志
|
||||
// System.out.println("==后置通知异常==");
|
||||
// System.out.println("异常信息:{}" + e.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常通知 用于拦截service层记录异常日志
|
||||
*
|
||||
* @param joinPoint
|
||||
* @param e
|
||||
*/
|
||||
@AfterThrowing(pointcut = "serviceAspect()", throwing = "e")
|
||||
public void doAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
||||
.getRequestAttributes()).getRequest();
|
||||
// // 读取session中的用户
|
||||
// Tblsysuser user = SessionUser.getsession(request);
|
||||
// // 获取请求ip
|
||||
// String ip = request.getRemoteAddr();
|
||||
// // 获取用户请求方法的参数并序列化为JSON格式字符串
|
||||
// String params = "";
|
||||
// if (joinPoint.getArgs() != null && joinPoint.getArgs().length > 0) {
|
||||
// for (int i = 0; i < joinPoint.getArgs().length; i++) {
|
||||
// params += joinPoint.getArgs()[i] + ";";
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// /* ========控制台输出========= */
|
||||
// System.out.println("=====异常通知开始=====");
|
||||
// System.out.println("异常代码:" + e.getClass().getName());
|
||||
// System.out.println("异常信息:" + e.getMessage());
|
||||
// System.out.println("异常方法:"
|
||||
// + (joinPoint.getTarget().getClass().getName() + "."
|
||||
// + joinPoint.getSignature().getName() + "()"));
|
||||
// System.out.println("方法描述:" + getServiceMthodDescription(joinPoint));
|
||||
// System.out.println("请求人:" + user.getSysusername());
|
||||
// System.out.println("请求IP:" + ip);
|
||||
// System.out.println("请求参数:" + params);
|
||||
// /* ==========数据库日志========= */
|
||||
// System.out.println("=====异常通知结束=====");
|
||||
// } catch (Exception ex) {
|
||||
// // 记录本地异常日志
|
||||
// System.out.println("==异常通知异常==");
|
||||
// System.out.println("异常信息:{}" + ex.getMessage());
|
||||
// }
|
||||
// /* ==========记录本地异常日志========== */
|
||||
// System.out.println("异常方法:" + joinPoint.getTarget().getClass().getName()
|
||||
// + joinPoint.getSignature().getName());
|
||||
// System.out.println("异常代码:" + e.getClass().getName());
|
||||
// System.out.println("异常信息:" + e.getMessage());
|
||||
// System.out.println("参数:" + params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于service层注解
|
||||
*
|
||||
* @param joinPoint
|
||||
* 切点
|
||||
* @return 方法描述
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getServiceMthodDescription(JoinPoint joinPoint)
|
||||
throws Exception {
|
||||
String targetName = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
Object[] arguments = joinPoint.getArgs();
|
||||
Class targetClass = Class.forName(targetName);
|
||||
Method[] methods = targetClass.getMethods();
|
||||
String description = "";
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
Class[] clazzs = method.getParameterTypes();
|
||||
if (clazzs.length == arguments.length) {
|
||||
description = method.getAnnotation(SystemServiceLog.class)
|
||||
.description();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||
*
|
||||
* @param joinPoint
|
||||
* 切点
|
||||
* @return 方法描述
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getControllerAfterMethodDescription(JoinPoint joinPoint)
|
||||
throws Exception {
|
||||
String targetName = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
Object[] arguments = joinPoint.getArgs();
|
||||
Class targetClass = Class.forName(targetName);
|
||||
Method[] methods = targetClass.getMethods();
|
||||
String description = "";
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
Class[] clazzs = method.getParameterTypes();
|
||||
if (clazzs.length == arguments.length) {
|
||||
description = method.getAnnotation(
|
||||
SystemControllerAfterLog.class).description();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||
*
|
||||
* @param joinPoint
|
||||
* 切点
|
||||
* @return 方法描述
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getControllerBeforeMethodDescription(
|
||||
JoinPoint joinPoint) throws Exception {
|
||||
String targetName = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
Object[] arguments = joinPoint.getArgs();
|
||||
Class targetClass = Class.forName(targetName);
|
||||
Method[] methods = targetClass.getMethods();
|
||||
String description = "";
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
Class[] clazzs = method.getParameterTypes();
|
||||
if (clazzs.length == arguments.length) {
|
||||
description = method.getAnnotation(
|
||||
SystemControllerBeforeLog.class).description();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.dubh.syslog.annotation;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-5-18 下午12:45:10
|
||||
* 类说明:自定义注解 拦截service
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SystemServiceLog {
|
||||
|
||||
String description() default "";
|
||||
|
||||
|
||||
}
|
||||
10
src/main/java/com/hessian/HessianService.java
Normal file
10
src/main/java/com/hessian/HessianService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.hessian;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-12-16 下午4:58:10
|
||||
* 类说明
|
||||
*/
|
||||
public interface HessianService {
|
||||
|
||||
public String getName(String names);
|
||||
}
|
||||
15
src/main/java/com/ljh/excel/annotation/ColumnAnnotation.java
Normal file
15
src/main/java/com/ljh/excel/annotation/ColumnAnnotation.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.ljh.excel.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
//字段注解,对应excel里面的列
|
||||
public @interface ColumnAnnotation {
|
||||
public String value() default "A";
|
||||
}
|
||||
73
src/main/java/com/ljh/excel/bean/BaseBean.java
Normal file
73
src/main/java/com/ljh/excel/bean/BaseBean.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.ljh.excel.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ljh.excel.parser.BeanOperation;
|
||||
import com.ljh.excel.parser.Parser;
|
||||
|
||||
public class BaseBean {
|
||||
public List selectAll() {
|
||||
Parser p = new Parser(this.getClass());
|
||||
try {
|
||||
List list = p.processAllSheets();
|
||||
// System.out.println(list);
|
||||
return list;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List selectAll(String filename) throws Exception{
|
||||
Parser p = new Parser(this.getClass());
|
||||
try {
|
||||
List list = p.processAllSheets(filename);
|
||||
// System.out.println(list);
|
||||
return list;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>bean<61><6E><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>ϣ<EFBFBD><CFA3>Ḳ<EFBFBD><E1B8B2>ԭ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD>
|
||||
public void saveAll(List<? extends BaseBean> data) {
|
||||
BeanOperation p = new BeanOperation();
|
||||
try {
|
||||
p.saveAll(data);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveAll(List<? extends BaseBean> data, String filename) {
|
||||
BeanOperation p = new BeanOperation();
|
||||
try {
|
||||
p.saveAll(data, filename);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAll(List<? extends BaseBean> data) {
|
||||
BeanOperation p = new BeanOperation();
|
||||
try {
|
||||
p.addAll(data);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteByIndex(int index) {
|
||||
BeanOperation p = new BeanOperation();
|
||||
p.deleteByIndex(index, this.getClass());
|
||||
}
|
||||
}
|
||||
20
src/main/java/com/ljh/excel/bean/factory/ExcelFactory.java
Normal file
20
src/main/java/com/ljh/excel/bean/factory/ExcelFactory.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.ljh.excel.bean.factory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ExcelFactory {
|
||||
public static String PACTORYPATH = "";
|
||||
|
||||
private ExcelFactory() {
|
||||
}
|
||||
|
||||
public static void instance(String path) {
|
||||
PACTORYPATH = path;
|
||||
File f = new File(path);
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
|
||||
}else{
|
||||
f.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
100
src/main/java/com/ljh/excel/parser/BaseParser.java
Normal file
100
src/main/java/com/ljh/excel/parser/BaseParser.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.ljh.excel.parser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
import org.apache.poi.xssf.model.StylesTable;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import com.ljh.excel.bean.factory.ExcelFactory;
|
||||
|
||||
public class BaseParser {
|
||||
public static ContentHandler handler;
|
||||
protected List beanList = new ArrayList<>();
|
||||
protected Class cls;
|
||||
protected Object bean;
|
||||
protected SharedStringsTable sst;
|
||||
protected StylesTable stylesTable;
|
||||
|
||||
public void processFirstSheet(String filename) throws Exception {
|
||||
OPCPackage pkg = OPCPackage.open(filename);
|
||||
XSSFReader r = new XSSFReader(pkg);
|
||||
SharedStringsTable sst = r.getSharedStringsTable();
|
||||
|
||||
XMLReader parser = fetchSheetParser(sst);
|
||||
stylesTable = r.getStylesTable();
|
||||
// To look up the Sheet Name / Sheet Order / rID,
|
||||
// you need to process the core Workbook stream.
|
||||
// Normally it's of the form rId# or rSheet#
|
||||
InputStream sheet2 = r.getSheet("rId2");
|
||||
InputSource sheetSource = new InputSource(sheet2);
|
||||
parser.parse(sheetSource);
|
||||
sheet2.close();
|
||||
}
|
||||
|
||||
public List processAllSheets() throws Exception {
|
||||
|
||||
return processAllSheets(cls.getSimpleName());
|
||||
}
|
||||
|
||||
public List processAllSheets(String filename) throws Exception {
|
||||
|
||||
OPCPackage pkg = OPCPackage.open(filename);
|
||||
XSSFReader r = new XSSFReader(pkg);
|
||||
SharedStringsTable sst = r.getSharedStringsTable();
|
||||
|
||||
XMLReader parser = fetchSheetParser(sst);
|
||||
stylesTable = r.getStylesTable();
|
||||
|
||||
Iterator<InputStream> sheets = r.getSheetsData();
|
||||
int i=0;
|
||||
while (sheets.hasNext()) {
|
||||
// System.out.println("Processing new sheet:\n");
|
||||
InputStream sheet = sheets.next();
|
||||
InputSource sheetSource = new InputSource(sheet);
|
||||
parser.parse(sheetSource);
|
||||
sheet.close();
|
||||
if (beanList != null && bean != null) {
|
||||
beanList.add(bean);
|
||||
System.out.println("bean-->");
|
||||
}
|
||||
break;
|
||||
// System.out.println("end-->");
|
||||
}
|
||||
return beanList;
|
||||
}
|
||||
|
||||
static XMLReader xmlReader = null;
|
||||
static {
|
||||
try {
|
||||
xmlReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException {
|
||||
XMLReader xmlReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
|
||||
// ContentHandler handler = new SheetHandler(sst);
|
||||
this.sst = sst;
|
||||
xmlReader.setContentHandler(handler);
|
||||
return xmlReader;
|
||||
}
|
||||
|
||||
}
|
||||
248
src/main/java/com/ljh/excel/parser/BeanOperation.java
Normal file
248
src/main/java/com/ljh/excel/parser/BeanOperation.java
Normal file
@@ -0,0 +1,248 @@
|
||||
package com.ljh.excel.parser;
|
||||
|
||||
import com.ljh.excel.annotation.ColumnAnnotation;
|
||||
import com.ljh.excel.bean.BaseBean;
|
||||
import com.ljh.excel.bean.factory.ExcelFactory;
|
||||
import org.apache.poi.xssf.streaming.SXSSFRow;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//
|
||||
public class BeanOperation {
|
||||
public void saveAll(List<? extends BaseBean> data) throws Exception {
|
||||
saveAll(data, data.get(0).getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public void saveAll(List<? extends BaseBean> data, String filename) throws Exception {
|
||||
// if (data.size() > 10000) {
|
||||
// boolean tag = true;
|
||||
// List data1 = new LinkedList<>();
|
||||
//
|
||||
// while (tag) {
|
||||
// int i = 0;
|
||||
// boolean tag2 = true;
|
||||
// while (tag2) {
|
||||
// if (data.size()>0) {
|
||||
// i++;
|
||||
// data1.add(data.get(0));
|
||||
// data.remove(0);
|
||||
// } else {
|
||||
// tag = false;
|
||||
// break;
|
||||
// }
|
||||
// if (i >= 5000) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// addAll(data1, filename);
|
||||
// data1.clear();
|
||||
// }
|
||||
// data.clear();
|
||||
// } else {
|
||||
// saveData(data,filename);
|
||||
// }
|
||||
|
||||
saveData(data, filename);
|
||||
|
||||
}
|
||||
|
||||
public void saveData(List data, String filename) throws Exception {
|
||||
System.out.println("saveAll:" + filename + " data:" + data.size());
|
||||
SXSSFWorkbook wb = new SXSSFWorkbook(10000);
|
||||
SXSSFSheet sheet = wb.createSheet("sheet1");
|
||||
createCell(data, sheet, 0);
|
||||
new File(new File(filename).getParent()).mkdirs();
|
||||
FileOutputStream fout = new FileOutputStream(filename);
|
||||
wb.write(fout);
|
||||
fout.close();
|
||||
wb.dispose();
|
||||
System.out.println("saveData-end" );
|
||||
}
|
||||
|
||||
public void addAll(List<? extends BaseBean> data) throws Exception {
|
||||
addAll(data, data.get(0).getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public void addAll(List<? extends BaseBean> data, String filename) throws Exception {
|
||||
if (new File(ExcelFactory.PACTORYPATH + "/" + filename + ".xlsx").exists()
|
||||
&& new File(ExcelFactory.PACTORYPATH + "/" + filename + ".xlsx").isFile()) {
|
||||
System.out.println("addAll---");
|
||||
} else {
|
||||
saveData(new ArrayList<>(), filename);
|
||||
}
|
||||
FileInputStream fs = new FileInputStream(ExcelFactory.PACTORYPATH +
|
||||
"/" + filename + ".xlsx");
|
||||
XSSFWorkbook wb = new XSSFWorkbook(fs);
|
||||
// SXSSFWorkbook wb = new SXSSFWorkbook(wb1);
|
||||
|
||||
XSSFSheet sheet = wb.getSheetAt(0);
|
||||
XSSFRow row = sheet.getRow(0); //
|
||||
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
ExcelFactory.PACTORYPATH + "/" + filename + ".xlsx"); //
|
||||
createCell(data, sheet, sheet.getLastRowNum() + 1);
|
||||
out.flush();
|
||||
wb.write(out);
|
||||
out.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void createCell(List<? extends BaseBean> data, SXSSFSheet sheet, int first) {
|
||||
SXSSFRow row;
|
||||
int i = first;
|
||||
String fname;
|
||||
String s1;
|
||||
ColumnAnnotation canno;
|
||||
String s2;
|
||||
Method m;
|
||||
boolean tag = false;
|
||||
if (data != null && data.size() > 0) {
|
||||
tag = true;
|
||||
}
|
||||
while (tag) {
|
||||
BaseBean bean = data.get(0);
|
||||
//System.out.println("createCell" + i);
|
||||
Class c = bean.getClass();
|
||||
Field[] filds = c.getDeclaredFields();
|
||||
row = sheet.createRow(i);
|
||||
i++;
|
||||
|
||||
for (Field f : filds) {
|
||||
f.setAccessible(true);
|
||||
canno = f.getAnnotation(ColumnAnnotation.class);
|
||||
if (canno != null) {
|
||||
fname = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
|
||||
s1 = canno.value();
|
||||
try {
|
||||
m = c.getDeclaredMethod(fname, new Class[] {});
|
||||
m.setAccessible(true);
|
||||
s2 = (String) m.invoke(bean);
|
||||
|
||||
char[] c1 = s1.toCharArray();
|
||||
int index = (int) c1[0] - 65;
|
||||
try {
|
||||
int index2= (int) c1[1] - 65;
|
||||
index=26+index2;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
//System.out.println("canno:"+s1+" index:"+index);
|
||||
row.createCell((short) index).setCellValue(s2);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
data.remove(0);
|
||||
if (data.size() > 0) {
|
||||
tag = true;
|
||||
} else {
|
||||
tag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void createCell(List<? extends BaseBean> data, XSSFSheet sheet, int first) {
|
||||
XSSFRow row;
|
||||
int i = first;
|
||||
String fname;
|
||||
String s1;
|
||||
ColumnAnnotation canno;
|
||||
String s2;
|
||||
Method m;
|
||||
boolean tag = false;
|
||||
if (data != null && data.size() > 0) {
|
||||
tag = true;
|
||||
}
|
||||
while (tag) {
|
||||
BaseBean bean = data.get(0);
|
||||
System.out.println("createCell" + i);
|
||||
Class c = bean.getClass();
|
||||
Field[] filds = c.getDeclaredFields();
|
||||
row = sheet.createRow(i);
|
||||
i++;
|
||||
|
||||
for (Field f : filds) {
|
||||
f.setAccessible(true);
|
||||
canno = f.getAnnotation(ColumnAnnotation.class);
|
||||
if (canno != null) {
|
||||
fname = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
|
||||
s1 = canno.value();
|
||||
try {
|
||||
m = c.getDeclaredMethod(fname, new Class[] {});
|
||||
m.setAccessible(true);
|
||||
s2 = (String) m.invoke(bean);
|
||||
|
||||
char[] c1 = s1.toCharArray();
|
||||
int index = (int) c1[0] - 65;
|
||||
try {
|
||||
int index2= (int) c1[1] - 65;
|
||||
index=26+index2;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
System.out.println("canno:"+s1+" index:"+index);
|
||||
row.createCell((short) index).setCellValue(s2);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
data.remove(0);
|
||||
if (data.size() > 0) {
|
||||
tag = true;
|
||||
} else {
|
||||
tag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteByIndex(int index, Class cls) {
|
||||
try {
|
||||
|
||||
FileInputStream is = new FileInputStream(ExcelFactory.PACTORYPATH + "/" + cls.getSimpleName() + ".xlsx");
|
||||
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(is);
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
removeRow(sheet, index);
|
||||
FileOutputStream os = new FileOutputStream(ExcelFactory.PACTORYPATH + "/" + cls.getSimpleName() + ".xlsx");
|
||||
|
||||
workbook.write(os);
|
||||
|
||||
is.close();
|
||||
|
||||
os.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRow(XSSFSheet sheet, int rowIndex) {
|
||||
int lastRowNum = sheet.getLastRowNum();
|
||||
if (rowIndex >= 0 && rowIndex < lastRowNum)
|
||||
sheet.shiftRows(rowIndex + 1, lastRowNum, -1);
|
||||
if (rowIndex == lastRowNum) {
|
||||
XSSFRow removingRow = sheet.getRow(rowIndex);
|
||||
if (removingRow != null)
|
||||
sheet.removeRow(removingRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
142
src/main/java/com/ljh/excel/parser/FromHowTo.java
Normal file
142
src/main/java/com/ljh/excel/parser/FromHowTo.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package com.ljh.excel.parser;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
/**
|
||||
* XSSF and SAX (Event API) basic example.
|
||||
* See {@link XLSX2CSV} for a fuller example of doing
|
||||
* XSLX processing with the XSSF Event code.
|
||||
*/
|
||||
public class FromHowTo {
|
||||
public void processFirstSheet(String filename) throws Exception {
|
||||
OPCPackage pkg = OPCPackage.open(filename);
|
||||
XSSFReader r = new XSSFReader( pkg );
|
||||
SharedStringsTable sst = r.getSharedStringsTable();
|
||||
|
||||
XMLReader parser = fetchSheetParser(sst);
|
||||
|
||||
// To look up the Sheet Name / Sheet Order / rID,
|
||||
// you need to process the core Workbook stream.
|
||||
// Normally it's of the form rId# or rSheet#
|
||||
InputStream sheet2 = r.getSheet("rId2");
|
||||
InputSource sheetSource = new InputSource(sheet2);
|
||||
parser.parse(sheetSource);
|
||||
sheet2.close();
|
||||
}
|
||||
|
||||
public static void processAllSheets(String filename) throws Exception {
|
||||
OPCPackage pkg = OPCPackage.open(filename);
|
||||
XSSFReader r = new XSSFReader( pkg );
|
||||
SharedStringsTable sst = r.getSharedStringsTable();
|
||||
|
||||
XMLReader parser = fetchSheetParser(sst);
|
||||
|
||||
Iterator<InputStream> sheets = r.getSheetsData();
|
||||
while(sheets.hasNext()) {
|
||||
System.out.println("Processing new sheet:\n");
|
||||
InputStream sheet = sheets.next();
|
||||
InputSource sheetSource = new InputSource(sheet);
|
||||
parser.parse(sheetSource);
|
||||
sheet.close();
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
public static XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException {
|
||||
XMLReader parser =
|
||||
XMLReaderFactory.createXMLReader(
|
||||
"org.apache.xerces.parsers.SAXParser"
|
||||
);
|
||||
ContentHandler handler = new SheetHandler(sst);
|
||||
parser.setContentHandler(handler);
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* See org.xml.sax.helpers.DefaultHandler javadocs
|
||||
*/
|
||||
private static class SheetHandler extends DefaultHandler {
|
||||
private SharedStringsTable sst;
|
||||
private String lastContents;
|
||||
private boolean nextIsString;
|
||||
|
||||
private SheetHandler(SharedStringsTable sst) {
|
||||
this.sst = sst;
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String name,
|
||||
Attributes attributes) throws SAXException {
|
||||
// c => cell
|
||||
if(name.equals("c")) {
|
||||
// Print the cell reference
|
||||
System.out.print(attributes.getValue("r") + " - ");
|
||||
// Figure out if the value is an index in the SST
|
||||
String cellType = attributes.getValue("t");
|
||||
if(cellType != null && cellType.equals("s")) {
|
||||
nextIsString = true;
|
||||
} else {
|
||||
nextIsString = false;
|
||||
}
|
||||
}
|
||||
// Clear contents cache
|
||||
lastContents = "";
|
||||
}
|
||||
|
||||
public void endElement(String uri, String localName, String name)
|
||||
throws SAXException {
|
||||
// Process the last contents as required.
|
||||
// Do now, as characters() may be called more than once
|
||||
if(nextIsString) {
|
||||
int idx = Integer.parseInt(lastContents);
|
||||
lastContents = new XSSFRichTextString(sst.getEntryAt(idx)).toString();
|
||||
nextIsString = false;
|
||||
}
|
||||
|
||||
// v => contents of a cell
|
||||
// Output after we've seen the string contents
|
||||
if(name.equals("v")) {
|
||||
System.out.println(lastContents);
|
||||
}
|
||||
}
|
||||
|
||||
public void characters(char[] ch, int start, int length)
|
||||
throws SAXException {
|
||||
lastContents += new String(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
FromHowTo howto = new FromHowTo();
|
||||
howto.processFirstSheet(args[0]);
|
||||
howto.processAllSheets(args[0]);
|
||||
}
|
||||
}
|
||||
255
src/main/java/com/ljh/excel/parser/Parser.java
Normal file
255
src/main/java/com/ljh/excel/parser/Parser.java
Normal file
@@ -0,0 +1,255 @@
|
||||
package com.ljh.excel.parser;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
import org.apache.poi.xssf.model.StylesTable;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import com.ljh.excel.annotation.ColumnAnnotation;
|
||||
import com.ljh.excel.test.User;
|
||||
|
||||
public class Parser extends BaseParser {
|
||||
/**
|
||||
* See org.xml.sax.helpers.DefaultHandler javadocs
|
||||
*/
|
||||
/**
|
||||
*/
|
||||
private CellDataType nextDataType = CellDataType.SSTINDEX;
|
||||
|
||||
private final DataFormatter formatter = new DataFormatter();
|
||||
private short formatIndex;
|
||||
|
||||
private String formatString;
|
||||
|
||||
public Parser(Class cl) {
|
||||
cls = cl;
|
||||
}
|
||||
|
||||
public XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException {
|
||||
ContentHandler handler = new SheetHandler(sst);
|
||||
xmlReader.setContentHandler(handler);
|
||||
return xmlReader;
|
||||
}
|
||||
|
||||
class SheetHandler extends DefaultHandler {
|
||||
private SharedStringsTable sst;
|
||||
private String lastContents;
|
||||
private boolean nextIsString;
|
||||
|
||||
private SheetHandler(SharedStringsTable sst) {
|
||||
this.sst = sst;
|
||||
|
||||
}
|
||||
|
||||
String lastTag = "";
|
||||
String con = "";
|
||||
int i=0;
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
|
||||
// c => cell
|
||||
if (name.equals("c")) {
|
||||
setNextDataType(attributes);
|
||||
|
||||
String attributest = attributes.getValue("r");
|
||||
String attributestr = attributest.substring(1).replaceAll("[A-Z]*", "");
|
||||
con = attributest.replaceAll("[0-9]*", "");
|
||||
if (attributestr != null && !attributestr.equals("")
|
||||
&& (lastTag.equals("") || !attributestr.equals(lastTag))) {
|
||||
lastTag = attributestr;
|
||||
|
||||
// System.out.println("");
|
||||
|
||||
if (bean != null) {
|
||||
beanList.add(bean);
|
||||
|
||||
// if(i%2000==0){
|
||||
// System.gc();
|
||||
// }
|
||||
// System.out.println("bean:"+(i++)+"->" + bean);
|
||||
System.out.println("bean:"+(i++)+"->" );
|
||||
}
|
||||
try {
|
||||
bean = cls.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
// Print the cell reference
|
||||
// System.out.print("(->"+attributes.getValue("r") + " - ");
|
||||
// Figure out if the value is an index in the SST
|
||||
String cellType = attributes.getValue("t");
|
||||
if (cellType != null && cellType.equals("s")) {
|
||||
nextIsString = true;
|
||||
} else {
|
||||
nextIsString = false;
|
||||
}
|
||||
}
|
||||
// Clear contents cache
|
||||
lastContents = "";
|
||||
}
|
||||
|
||||
public void endElement(String uri, String localName, String name) throws SAXException {
|
||||
// Process the last contents as required.
|
||||
// Do now, as characters() may be called more than once
|
||||
if (nextIsString) {
|
||||
int idx = Integer.parseInt(lastContents);
|
||||
lastContents =new WeakReference<XSSFRichTextString>(new XSSFRichTextString(sst.getEntryAt(idx))).get().toString();
|
||||
nextIsString = false;
|
||||
}
|
||||
|
||||
// v => contents of a cell
|
||||
// Output after we've seen the string contents
|
||||
if (name.equals("v") || "t".equals(name)) {
|
||||
Class c = bean.getClass();
|
||||
Field[] fs = c.getDeclaredFields();
|
||||
|
||||
for (Field f : fs) {
|
||||
f.setAccessible(true);
|
||||
ColumnAnnotation canno = f.getAnnotation(ColumnAnnotation.class);
|
||||
if (canno != null && canno.value().equals(con)) {
|
||||
String fname = "set" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
|
||||
try {
|
||||
Method m = c.getDeclaredMethod(fname, new Class[] { String.class });
|
||||
m.setAccessible(true);
|
||||
// v => <20><>Ԫ<EFBFBD><D4AA><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>v<EFBFBD><76>ǩ<EFBFBD><C7A9>ֵΪ<D6B5><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>SST<53>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
String value = getDataValue(lastContents.trim(), "");
|
||||
System.out.println(fname+lastContents.trim());
|
||||
m.invoke(bean, value.trim());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
lastContents += new String(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
enum CellDataType {
|
||||
BOOL, ERROR, FORMULA, INLINESTR, SSTINDEX, NUMBER, DATE, NULL
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attributes
|
||||
*/
|
||||
public void setNextDataType(Attributes attributes) {
|
||||
try {
|
||||
nextDataType = CellDataType.NUMBER;
|
||||
formatIndex = -1;
|
||||
formatString = null;
|
||||
String cellType = attributes.getValue("t");
|
||||
String cellStyleStr = attributes.getValue("s");
|
||||
|
||||
if ("b".equals(cellType)) {
|
||||
nextDataType = CellDataType.BOOL;
|
||||
} else if ("e".equals(cellType)) {
|
||||
nextDataType = CellDataType.ERROR;
|
||||
} else if ("inlineStr".equals(cellType)) {
|
||||
nextDataType = CellDataType.INLINESTR;
|
||||
} else if ("s".equals(cellType)) {
|
||||
nextDataType = CellDataType.SSTINDEX;
|
||||
} else if ("str".equals(cellType)) {
|
||||
nextDataType = CellDataType.FORMULA;
|
||||
}
|
||||
|
||||
if (cellStyleStr != null) {
|
||||
int styleIndex = Integer.parseInt(cellStyleStr);
|
||||
XSSFCellStyle style = stylesTable.getStyleAt(styleIndex);
|
||||
formatIndex = style.getDataFormat();
|
||||
formatString = style.getDataFormatString();
|
||||
|
||||
if ("m/d/yy".equals(formatString) || "m/d/yy h:mm".equals(formatString)) {
|
||||
nextDataType = CellDataType.DATE;
|
||||
formatString = "yyyy/MM/dd hh:mm:ss";
|
||||
}
|
||||
|
||||
if (formatString == null) {
|
||||
nextDataType = CellDataType.NULL;
|
||||
formatString = BuiltinFormats.getBuiltinFormat(formatIndex);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getDataValue(String value, String thisStr) {
|
||||
switch (nextDataType) {
|
||||
case BOOL:
|
||||
char first = value.charAt(0);
|
||||
thisStr = first == '0' ? "FALSE" : "TRUE";
|
||||
break;
|
||||
case ERROR:
|
||||
thisStr = "\"ERROR:" + value.toString() + '"';
|
||||
break;
|
||||
case FORMULA:
|
||||
thisStr = '"' + value.toString() + '"';
|
||||
break;
|
||||
case INLINESTR:
|
||||
XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
|
||||
|
||||
thisStr = rtsi.toString();
|
||||
rtsi = null;
|
||||
break;
|
||||
case SSTINDEX:
|
||||
String sstIndex = value.toString();
|
||||
try {
|
||||
int idx = Integer.parseInt(sstIndex);
|
||||
XSSFRichTextString rtss = new XSSFRichTextString(sst.getEntryAt(idx));
|
||||
thisStr = rtss.toString();
|
||||
rtss = null;
|
||||
} catch (Exception ex) {
|
||||
thisStr = value.toString();
|
||||
}
|
||||
break;
|
||||
case NUMBER:
|
||||
if (formatString != null) {
|
||||
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim();
|
||||
} else {
|
||||
thisStr = value;
|
||||
}
|
||||
|
||||
thisStr = thisStr.replace("_", "").trim();
|
||||
break;
|
||||
case DATE:
|
||||
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString);
|
||||
|
||||
// thisStr = thisStr.replace(" ", "T");
|
||||
break;
|
||||
default:
|
||||
thisStr = " ";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return thisStr;
|
||||
}
|
||||
}
|
||||
101
src/main/java/com/ljh/excel/test/MySqlTest.java
Normal file
101
src/main/java/com/ljh/excel/test/MySqlTest.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.ljh.excel.test;
|
||||
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.ljh.excel.bean.factory.ExcelFactory;
|
||||
|
||||
public class MySqlTest {
|
||||
public static void main(String[] args) throws SQLException {
|
||||
ExcelFactory.PACTORYPATH="F:\\vmx";
|
||||
List list=new ArrayList();
|
||||
list.add(new User());
|
||||
list.add(new User("ljh2","test","test"));
|
||||
list.add(new User("ljh3","test","test"));
|
||||
new User().saveAll(list,"F:\\text.xlsx");
|
||||
// Connection conn = null;
|
||||
// PreparedStatement stmt = null;
|
||||
// ResultSet rs = null;
|
||||
//
|
||||
// try {
|
||||
// Class.forName("com.mysql.jdbc.Driver");
|
||||
// conn = DriverManager.getConnection(
|
||||
// "jdbc:mysql://localhost:3306/jeecp", "root",
|
||||
// "");
|
||||
// stmt = conn.prepareStatement("select * from person where id=?");
|
||||
// stmt.setInt(1, 10);
|
||||
// rs = stmt.executeQuery();
|
||||
// while (rs.next()) {
|
||||
// System.out.println(rs.getInt("id"));
|
||||
// System.out.println(rs.getString("name"));
|
||||
// System.out.println("----------------------------");
|
||||
// }
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (rs != null)
|
||||
// rs.close();
|
||||
// if (stmt != null)
|
||||
// stmt.close();
|
||||
// if (conn != null)
|
||||
// conn.close();
|
||||
// }
|
||||
// Integer i1=new Integer("2");
|
||||
// Integer i2=new Integer("2");
|
||||
// System.out.println((int)i1==(int)i2);
|
||||
// try {
|
||||
//// List<ETabDispatch> datalist2 = new ETabDispatch().selectAll("C:/Users/junhui/Desktop/tes.xlsx");
|
||||
//// for(ETabDispatch ed:datalist2){
|
||||
//// System.out.println("ed:"+ed);
|
||||
//// }
|
||||
//// System.out.println("datalist2:"+datalist2.size());
|
||||
// ExcelFactory.instance("d://");
|
||||
// SevenParams p1=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p2=new SevenParams("SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p3=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p4=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// List list=new ArrayList<>();
|
||||
// list.add(p1);
|
||||
// list.add(p2);
|
||||
// list.add(p3);
|
||||
// list.add(p4);
|
||||
//
|
||||
// p1.saveAll(list,"d://SevenParams.xlsx");
|
||||
// } catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("days:"+daysBetween("2016-10-13 12:44:31","2016-10-15 12:44:31"));
|
||||
}
|
||||
/**
|
||||
*字符串的日期格式的计算
|
||||
*/
|
||||
public static int daysBetween(String smdate,String bdate){
|
||||
try {
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(sdf.parse(smdate));
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(sdf.parse(bdate));
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days=(time2-time1)/(1000*3600*24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
54
src/main/java/com/ljh/excel/test/User.java
Normal file
54
src/main/java/com/ljh/excel/test/User.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.ljh.excel.test;
|
||||
|
||||
import com.ljh.excel.annotation.ColumnAnnotation;
|
||||
import com.ljh.excel.bean.BaseBean;
|
||||
|
||||
public class User extends BaseBean {
|
||||
@ColumnAnnotation("A")
|
||||
private String name;
|
||||
@ColumnAnnotation("B")
|
||||
private String department;
|
||||
@ColumnAnnotation("C")
|
||||
private String hobby;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getHobby() {
|
||||
return hobby;
|
||||
}
|
||||
|
||||
public void setHobby(String hobby) {
|
||||
this.hobby = hobby;
|
||||
}
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(String name, String department, String hobby) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.department = department;
|
||||
this.hobby = hobby;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [name=" + name + ", department=" + department + ", hobby=" + hobby + "]";
|
||||
}
|
||||
|
||||
}
|
||||
17
src/main/java/com/quartz/UnlockOrder.java
Normal file
17
src/main/java/com/quartz/UnlockOrder.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.quartz;
|
||||
|
||||
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import com.util.SpringUtil;
|
||||
public class UnlockOrder implements Job {
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context){
|
||||
// OrderService service =(OrderService)SpringUtil.getBean("orderservice");
|
||||
// //解锁10分钟以前的数据
|
||||
// service.executeSql("update taborder tab1 set locksign=0 where DATE_SUB(now(),INTERVAL 10 MINUTE)>=tab1.createtime and locksign=1 ");
|
||||
//
|
||||
}
|
||||
}
|
||||
81
src/main/java/com/quartz/queryservlet.java
Normal file
81
src/main/java/com/quartz/queryservlet.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package com.quartz;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SchedulerFactory;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
/**
|
||||
* 监听策略信息
|
||||
* 获取预执行任务
|
||||
* @author dubaohui
|
||||
* */
|
||||
public class queryservlet extends HttpServlet {
|
||||
private static Scheduler sched =null;
|
||||
public queryservlet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public void init() throws ServletException {
|
||||
// SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
|
||||
// try {
|
||||
// sched = StdSchedulerFactory.getDefaultScheduler();
|
||||
// if(sched.isStarted()){
|
||||
// sched.shutdown(true); //如果已经启动 停止当前调度任务
|
||||
// sched = StdSchedulerFactory.getDefaultScheduler();
|
||||
// }
|
||||
// ServletContext sc = getServletContext();
|
||||
// WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
//
|
||||
// JobDetail jobDetai1 = new JobDetail("订单解锁", sched.DEFAULT_GROUP,UnlockOrder.class);
|
||||
// try {
|
||||
// Trigger trigger1 =new CronTrigger("启动订单解锁扫描", Scheduler.DEFAULT_GROUP,"0 0/10 * * * ?");
|
||||
// sched.scheduleJob(jobDetai1,trigger1);
|
||||
// sched.start();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// } catch (SchedulerException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
}
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException {
|
||||
// try {
|
||||
// if(sched.isStarted())
|
||||
// {
|
||||
// sched.shutdown(true);
|
||||
// }
|
||||
// if(sched.isShutdown())
|
||||
// {
|
||||
// init();
|
||||
// }
|
||||
// } catch (SchedulerException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException {
|
||||
// doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
59
src/main/java/com/util/AutoDtoFile.java
Normal file
59
src/main/java/com/util/AutoDtoFile.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AutoDtoFile {
|
||||
public static boolean creatDtoFile(String sqlTableName,String title,List list){
|
||||
if(null==title){
|
||||
title="";
|
||||
}
|
||||
String tableName=UtilTools.szmZdx(sqlTableName);
|
||||
StringBuffer buf=new StringBuffer();
|
||||
buf.append("package com.cn.pojo;\r\n"+
|
||||
"import javax.persistence.Column;\r\n"+
|
||||
"import javax.persistence.Entity;\r\n"+
|
||||
"import javax.persistence.Id;\r\n"+
|
||||
"import javax.persistence.Table;\r\n"+
|
||||
"import com.dubh.common.dto.BaseDto;\r\n\r\n" +
|
||||
"/**\r\n"+
|
||||
" * "+title+"\r\n"+
|
||||
" * @author zengwp\r\n"+
|
||||
" */\r\n"+
|
||||
" @Entity\r\n"+
|
||||
" @Table(name = \""+sqlTableName+"\")\r\n"+
|
||||
" public class "+tableName+" extends BaseDto {\r\n"+
|
||||
" \r\n");
|
||||
//生成字段变量
|
||||
for (int i = 0; i <list.size(); i++) {
|
||||
Object[] arr=(Object[])list.get(i);
|
||||
String strSty="String ";
|
||||
if(arr[1].toString().indexOf("int")>=0){
|
||||
strSty="Integer ";
|
||||
}
|
||||
buf.append("\t private "+strSty+arr[0]+";\r\n");
|
||||
}
|
||||
|
||||
//默认第一个为主键
|
||||
buf.append("\r\n\t @Id\r\n");
|
||||
|
||||
//GET和SET方法
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] arr=(Object[])list.get(i);
|
||||
String strSty="String ";
|
||||
if(arr[1].toString().indexOf("int")>=0){
|
||||
strSty="Integer ";
|
||||
}
|
||||
String optsName=UtilTools.szmZdx(arr[0].toString());
|
||||
buf.append("\t @Column(name = \""+arr[0]+"\")\r\n");
|
||||
buf.append("\t public "+strSty+" get"+optsName+"() {\r\n"+
|
||||
"\t return "+arr[0]+";\r\n"+
|
||||
"\t }\r\n"+
|
||||
"\t public void set"+optsName+"("+strSty+" "+arr[0]+") {\r\n"+
|
||||
"\t this."+arr[0]+" = "+arr[0]+";\r\n"+
|
||||
"\t }\r\n");
|
||||
}
|
||||
buf.append(" }");
|
||||
return NewFieldUtileTools.fileOperation("E:\\WorkSpace\\goldkey\\src\\com\\cn\\pojo",tableName+".java",buf.toString());
|
||||
|
||||
}
|
||||
}
|
||||
74
src/main/java/com/util/BaiDuDistanceKm.java
Normal file
74
src/main/java/com/util/BaiDuDistanceKm.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.util;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-10-8 下午3:51:18
|
||||
* 类说明 :计算坐标点之间的距离
|
||||
*/
|
||||
public class BaiDuDistanceKm {
|
||||
static double DEF_PI = 3.14159265359; // PI
|
||||
static double DEF_2PI= 6.28318530712; // 2*PI
|
||||
static double DEF_PI180= 0.01745329252; // PI/180.0
|
||||
static double DEF_R =6370693.5; // radius of earth
|
||||
//适用于近距离
|
||||
public static double GetShortDistance(double lng1, double lat1, double lng2, double lat2)
|
||||
{
|
||||
double ew1, ns1, ew2, ns2;
|
||||
double dx, dy, dew;
|
||||
double distance;
|
||||
double distancekm;
|
||||
// 角度转换为弧度
|
||||
ew1 = lng1 * DEF_PI180;
|
||||
ns1 = lat1 * DEF_PI180;
|
||||
ew2 = lng2 * DEF_PI180;
|
||||
ns2 = lat2 * DEF_PI180;
|
||||
// 经度差
|
||||
dew = ew1 - ew2;
|
||||
// 若跨东经和西经180 度,进行调整
|
||||
if (dew > DEF_PI)
|
||||
dew = DEF_2PI - dew;
|
||||
else if (dew < -DEF_PI)
|
||||
dew = DEF_2PI + dew;
|
||||
dx = DEF_R * Math.cos(ns1) * dew; // 东西方向长度(在纬度圈上的投影长度)
|
||||
dy = DEF_R * (ns1 - ns2); // 南北方向长度(在经度圈上的投影长度)
|
||||
// 勾股定理求斜边长
|
||||
distance = Math.sqrt(dx * dx + dy * dy);
|
||||
distancekm = Math.rint(distance/100)/10;
|
||||
return distancekm;
|
||||
}
|
||||
|
||||
//适用于远距离
|
||||
public static double GetLongDistance(double lng1, double lat1, double lng2, double lat2)
|
||||
{
|
||||
double ew1, ns1, ew2, ns2;
|
||||
double distance;
|
||||
double distancekm;
|
||||
// 角度转换为弧度
|
||||
ew1 = lng1 * DEF_PI180;
|
||||
ns1 = lat1 * DEF_PI180;
|
||||
ew2 = lng2 * DEF_PI180;
|
||||
ns2 = lat2 * DEF_PI180;
|
||||
// 求大圆劣弧与球心所夹的角(弧度)
|
||||
distance = Math.sin(ns1) * Math.sin(ns2) + Math.cos(ns1) * Math.cos(ns2) * Math.cos(ew1 - ew2);
|
||||
// 调整到[-1..1]范围内,避免溢出
|
||||
if (distance > 1.0)
|
||||
distance = 1.0;
|
||||
else if (distance < -1.0)
|
||||
distance = -1.0;
|
||||
// 求大圆劣弧长度
|
||||
distance = DEF_R * Math.acos(distance);
|
||||
distancekm = Math.rint(distance/100)/10;
|
||||
return distancekm;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
double mLat1 = 29.490295; // point1纬度
|
||||
double mLon1 = 106.486654; // point1经度
|
||||
double mLat2 = 29.615467;// point2纬度
|
||||
double mLon2 = 106.581515;// point2经度
|
||||
double distance = BaiDuDistanceKm.GetLongDistance(mLon1, mLat1, mLon2, mLat2);
|
||||
double distances = BaiDuDistanceKm.GetShortDistance(mLon1, mLat1, mLon2, mLat2);
|
||||
//double b = Math.rint(distance/100)/10;//
|
||||
System.out.println(distance+"----"+distances);
|
||||
}
|
||||
|
||||
}
|
||||
79
src/main/java/com/util/BaiduLatitudeUtils.java
Normal file
79
src/main/java/com/util/BaiduLatitudeUtils.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.util;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-10-8 下午3:45:59
|
||||
* 类说明:百度地址反解析
|
||||
*/
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class BaiduLatitudeUtils {
|
||||
|
||||
public static final String KEY_1 = "46aaaddd44217ffb415f20a5a4466bcd";
|
||||
|
||||
|
||||
/**
|
||||
* 返回输入地址的经纬度坐标
|
||||
* key lng(经度),lat(纬度)
|
||||
*/
|
||||
public static Map<String,String> getGeocoderLatitude(String address){
|
||||
BufferedReader in = null;
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
try {
|
||||
//将地址转换成utf-8的16进制
|
||||
address = URLEncoder.encode(address, "UTF-8");
|
||||
// 如果有代理,要设置代理,没代理可注释
|
||||
// System.setProperty("http.proxyHost","192.168.1.188");
|
||||
// System.setProperty("http.proxyPort","3128");
|
||||
URL tirc = new URL("http://api.map.baidu.com/geocoder?address="+ address +"&output=json&key="+ KEY_1);
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(tirc.openStream(),"UTF-8"));
|
||||
String res;
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
while((res = in.readLine())!=null){
|
||||
sb.append(res.trim());
|
||||
}
|
||||
String str = sb.toString();
|
||||
|
||||
if(StringUtils.isNotEmpty(str)){
|
||||
int lngStart = str.indexOf("lng\":");
|
||||
int lngEnd = str.indexOf(",\"lat");
|
||||
int latEnd = str.indexOf("},\"precise");
|
||||
if(lngStart > 0 && lngEnd > 0 && latEnd > 0){
|
||||
String lng =str.substring(lngStart+5, lngEnd);
|
||||
String lat = str.substring(lngEnd+7, latEnd);
|
||||
map.put("lng", lng); //经度
|
||||
map.put("lat", lat); //纬度
|
||||
}else{
|
||||
map.put("lng", "0"); //经度
|
||||
map.put("lat", "0"); //纬度
|
||||
}
|
||||
}else{
|
||||
map.put("lng", "0"); //经度
|
||||
map.put("lat", "0"); //纬度
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public static void main(String args[]){
|
||||
Map<String, String> json = BaiduLatitudeUtils.getGeocoderLatitude("上海沪南路2419弄");
|
||||
System.out.println("lng : "+json.get("lng")); //经度
|
||||
System.out.println("lat : "+json.get("lat")); //纬度
|
||||
}
|
||||
|
||||
}
|
||||
197
src/main/java/com/util/BuilderExcel.java
Normal file
197
src/main/java/com/util/BuilderExcel.java
Normal file
@@ -0,0 +1,197 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-8-12 下午2:57:13
|
||||
* 类说明:生成Excel工具类
|
||||
*/
|
||||
public class BuilderExcel
|
||||
{
|
||||
/**
|
||||
* @功能:手工构建一个简单格式的Excel
|
||||
*/
|
||||
private static List<Student> getStudent() throws Exception
|
||||
{
|
||||
List list = new ArrayList();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");
|
||||
Student user1 = new Student(1, "张三", 16, df.parse("1997-03-12"));
|
||||
Student user2 = new Student(2, "李四", 17, df.parse("1996-08-12"));
|
||||
Student user3 = new Student(3, "王五", 26, df.parse("1985-11-12"));
|
||||
list.add(user1);
|
||||
list.add(user2);
|
||||
list.add(user3);
|
||||
return list;
|
||||
}
|
||||
//生成Excel
|
||||
public static boolean Builderexcels(HttpServletRequest request,String sheetname,String[] heard,List list,String xlsname){
|
||||
boolean sign = false;
|
||||
// 第一步,创建一个webbook,对应一个Excel文件
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
|
||||
HSSFSheet sheet = wb.createSheet(sheetname);
|
||||
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
// 第四步,创建单元格,并设置值表头 设置表头居中
|
||||
HSSFCellStyle style =Tablestyle(wb, 14, true, true, true, 13, false);
|
||||
// 创建一个居中格式
|
||||
HSSFCell cell = null;
|
||||
int valuelength=0;
|
||||
if(heard.length>0){
|
||||
valuelength = heard.length;
|
||||
for(int i=0;i<heard.length;i++){
|
||||
cell = row.createCell(i);
|
||||
cell.setCellValue(heard[i]);
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
|
||||
HSSFCellStyle style1 =Tablestyle(wb, 12, false, true, true, 1, false);
|
||||
if(list !=null && list.size()>0){
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
int j=i+1;
|
||||
row = sheet.createRow(j);
|
||||
Object[] obj =(Object[])list.get(i);
|
||||
// 第四步,创建单元格,并设置值
|
||||
for(int t = 0;t<valuelength;t++){
|
||||
cell = row.createCell(t);
|
||||
cell.setCellStyle(style1);
|
||||
cell.setCellValue(RequestUtil.ReturnObjStr(obj[t]));
|
||||
}
|
||||
}
|
||||
}
|
||||
sign = true;
|
||||
// 第六步,将文件存到指定位置
|
||||
FileOutputStream fout=null;
|
||||
String paths = "";
|
||||
try{
|
||||
paths = request.getSession().getServletContext().getRealPath("attached")+File.separator+xlsname+".xls";
|
||||
fout = new FileOutputStream(paths);
|
||||
wb.write(fout);
|
||||
sign = true;
|
||||
}catch (Exception e){
|
||||
sign = false;
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
fout.close();
|
||||
wb.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
sign = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return sign;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
// // 第一步,创建一个webbook,对应一个Excel文件
|
||||
// HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
|
||||
// HSSFSheet sheet = wb.createSheet("学生表一");
|
||||
// // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
|
||||
// HSSFRow row = sheet.createRow((int) 0);
|
||||
// // 第四步,创建单元格,并设置值表头 设置表头居中
|
||||
// HSSFCellStyle style =Tablestyle(wb, 14, true, true, true, 13, false);
|
||||
// // 创建一个居中格式
|
||||
// HSSFCell cell = row.createCell(0);
|
||||
// cell.setCellValue("学号");
|
||||
// cell.setCellStyle(style);
|
||||
// cell = row.createCell(1);
|
||||
// cell.setCellValue("姓名");
|
||||
// cell.setCellStyle(style);
|
||||
// cell = row.createCell(2);
|
||||
// cell.setCellValue("年龄");
|
||||
// cell.setCellStyle(style);
|
||||
// cell = row.createCell(3);
|
||||
// cell.setCellValue("生日");
|
||||
// cell.setCellStyle(style);
|
||||
// // 第五步,写入实体数据 实际应用中这些数据从数据库得到,
|
||||
// List list = BuilderExcel.getStudent();
|
||||
// HSSFCellStyle style1 =Tablestyle(wb, 12, false, true, true, 1, false);
|
||||
// for (int i = 0; i < list.size(); i++)
|
||||
// {
|
||||
// row = sheet.createRow((int) i + 1);
|
||||
// Student stu = (Student) list.get(i);
|
||||
// // 第四步,创建单元格,并设置值
|
||||
// cell = row.createCell(0);
|
||||
// cell.setCellStyle(style1);
|
||||
// cell.setCellValue("111");
|
||||
// cell = row.createCell(1);
|
||||
// cell.setCellStyle(style1);
|
||||
// cell.setCellValue("2222");
|
||||
// cell = row.createCell(2);
|
||||
// cell.setCellStyle(style1);
|
||||
// cell.setCellValue("3333");
|
||||
// cell = row.createCell(3);
|
||||
// cell.setCellStyle(style1);
|
||||
// cell.setCellValue(new SimpleDateFormat("yyyy-mm-dd").format(stu.getBirth()));
|
||||
// }
|
||||
// // 第六步,将文件存到指定位置
|
||||
// try
|
||||
// {
|
||||
// FileOutputStream fout = new FileOutputStream("/Users/dubaohui/Desktop/students.xls");
|
||||
// wb.write(fout);
|
||||
// fout.close();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 表样式
|
||||
* @param fontsize 字体大小
|
||||
* @param isfontbold 是否粗体
|
||||
* @param isborder 是否存在边框
|
||||
* @param isgroundcolor 是否设置背景颜色
|
||||
* @param iswaptext 是否自动换行
|
||||
* @return HSSFCellStyle
|
||||
* */
|
||||
private static HSSFCellStyle Tablestyle(HSSFWorkbook wb,int fontsize,boolean isfontbold,boolean isborder,boolean isgroundcolor,int groundcolor,boolean iswaptext){
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
if(isborder){
|
||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
|
||||
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
|
||||
style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
|
||||
style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
|
||||
}
|
||||
if(isgroundcolor){
|
||||
style.setFillForegroundColor((short) groundcolor);// 设置背景色
|
||||
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
||||
}
|
||||
style.setWrapText(iswaptext);
|
||||
HSSFFont font = wb.createFont();
|
||||
font.setFontName("黑体");
|
||||
font.setFontHeightInPoints((short) fontsize);//设置字体大小
|
||||
if(isfontbold){
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
|
||||
}
|
||||
style.setFont(font);
|
||||
return style;
|
||||
}
|
||||
|
||||
}
|
||||
42
src/main/java/com/util/Check.java
Normal file
42
src/main/java/com/util/Check.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.util;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* 检测用户是否登录超时
|
||||
* @author dubaohui
|
||||
* */
|
||||
public class Check extends HttpServlet implements Filter {
|
||||
|
||||
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest srequest, ServletResponse sresponse,
|
||||
FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest)srequest;
|
||||
HttpServletResponse response = (HttpServletResponse)sresponse;
|
||||
// Tblsysuser dto =SessionUser.getsession(request);
|
||||
// if (dto == null)
|
||||
// {
|
||||
// System.out.println("****************检测到用户Session已经消失****************");
|
||||
// String flgvalue = Escape.escape(Configmessage.checkloginflg(3));
|
||||
// response.sendRedirect(request.getContextPath()+"/login.jsp?loginlog="+flgvalue+"");
|
||||
// }else{
|
||||
// filterChain.doFilter(srequest, sresponse);
|
||||
// }
|
||||
}
|
||||
|
||||
public void init(FilterConfig arg0) throws ServletException {
|
||||
}
|
||||
|
||||
}
|
||||
45
src/main/java/com/util/ComTreeInfo.java
Normal file
45
src/main/java/com/util/ComTreeInfo.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.util;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-8-10 下午5:13:08
|
||||
* 类说明
|
||||
*/
|
||||
public class ComTreeInfo {
|
||||
|
||||
private String id;
|
||||
private String text;
|
||||
private Boolean checked;
|
||||
private String state;
|
||||
private String iconCls;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getIconCls() {
|
||||
return iconCls;
|
||||
}
|
||||
public void setIconCls(String iconCls) {
|
||||
this.iconCls = iconCls;
|
||||
}
|
||||
}
|
||||
51
src/main/java/com/util/Configmessage.java
Normal file
51
src/main/java/com/util/Configmessage.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Configmessage {
|
||||
public static final String SAVESUCC="创建成功!";
|
||||
public static final String SAVEFINAL="创建失败!";
|
||||
public static final String UPDATESUCC="编辑成功!";
|
||||
public static final String UPDATEFINAL="编辑失败!";
|
||||
public static final String DELECESUCC="删除成功!";
|
||||
public static final String DELECEFINAL="删除失败!";
|
||||
public static final String SETINGSUCC="设置成功!";
|
||||
public static final String SETINGFINAL="设置失败!";
|
||||
public static final String YHCS="登录超时,请重新登录!";
|
||||
public static final String REDSUCC="调动成功!";
|
||||
public static final String REDFINAL="调动失败!";
|
||||
public static final String INITSUCC="初始化成功!";
|
||||
public static final String INITFINAL="初始化失败!";
|
||||
public static final String CAOZYES="操作成功!";
|
||||
public static final String CAOZNO="操作失败!";
|
||||
|
||||
/**
|
||||
*
|
||||
* 用户登录
|
||||
* @author dubaohui
|
||||
* @param int
|
||||
* @return String
|
||||
* */
|
||||
public static String checkloginflg(int flg){
|
||||
if(flg==0){
|
||||
return "登录成功!";
|
||||
}else if(flg==1){
|
||||
return "验证码错误!";
|
||||
}else if(flg==2){
|
||||
return "用户名不存在!";
|
||||
}else if(flg==3){
|
||||
return "密码输入错误!";
|
||||
}else if(flg==4){
|
||||
return "帐号已被冻结,请联系管理员!";
|
||||
}else if(flg==5){
|
||||
return "无权限登录!";
|
||||
}else if(flg==101){
|
||||
return "请重新登录!";
|
||||
}else{
|
||||
return "登录失败!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
51
src/main/java/com/util/Distance.java
Normal file
51
src/main/java/com/util/Distance.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.util;
|
||||
|
||||
/**
|
||||
* Created by TEC2 on 2017/2/7.
|
||||
*/
|
||||
public class Distance {
|
||||
private static final double EARTH_RADIUS = 6378.137;
|
||||
|
||||
private static double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据两个位置的经纬度,来计算两地的距离(单位为KM)
|
||||
* 参数为double类型
|
||||
* long1 位置1经度
|
||||
* lat1 位置1纬度
|
||||
* long2 位置2经度
|
||||
* lat2 位置2纬度
|
||||
*/
|
||||
public static double GetDistance(double long1, double lat1, double long2, double lat2) {
|
||||
double a, b, d, sa2, sb2;
|
||||
lat1 = rad(lat1);
|
||||
lat2 = rad(lat2);
|
||||
a = Math.abs(lat1 - lat2);
|
||||
b = rad(Math.abs(long1 - long2));
|
||||
|
||||
sa2 = Math.sin(a / 2.0);
|
||||
sb2 = Math.sin(b / 2.0);
|
||||
d = 2 * EARTH_RADIUS
|
||||
* Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1)
|
||||
* Math.cos(lat2) * sb2 * sb2));
|
||||
return d;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//根据两点间的经纬度计算距离,单位:km
|
||||
// System.out.println(GetDistance(116.5542, 39.81621, 116.5539, 39.81616));
|
||||
// System.out.println(GetDistance(117.1181, 36.68484, 117.01, 36.66123));
|
||||
// System.out.println(GetDistance(112.9084, 28.14203, 112.9083, 28.14194));
|
||||
// System.out.println(GetDistance(121.5373, 38.86827, 121.5372, 38.86832));
|
||||
// System.out.println(GetDistance(20.5, 118.2, 21.1, 117.6));
|
||||
// System.out.println(GetDistance( 121.444832,31.179313,121.445140,31.177779));
|
||||
String s=String.valueOf((Math.random() * 9000 + 1000));
|
||||
s="012345";
|
||||
System.out.println(s);
|
||||
System.out.println(s.substring(0,s.length()-1));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
131
src/main/java/com/util/Escape.java
Normal file
131
src/main/java/com/util/Escape.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.util;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* java Escape 加解密
|
||||
* 应用于 javascript加密 java解密
|
||||
* @author dubaohui
|
||||
* keep this copyright info while using this method by free
|
||||
*/
|
||||
public class Escape{
|
||||
private final static String[] hex = {
|
||||
"00","01","02","03","04","05","06","07","08","09","0A","0B","0C","0D","0E","0F",
|
||||
"10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F",
|
||||
"20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F",
|
||||
"30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F",
|
||||
"40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F",
|
||||
"50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F",
|
||||
"60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F",
|
||||
"70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F",
|
||||
"80","81","82","83","84","85","86","87","88","89","8A","8B","8C","8D","8E","8F",
|
||||
"90","91","92","93","94","95","96","97","98","99","9A","9B","9C","9D","9E","9F",
|
||||
"A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","AA","AB","AC","AD","AE","AF",
|
||||
"B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","BA","BB","BC","BD","BE","BF",
|
||||
"C0","C1","C2","C3","C4","C5","C6","C7","C8","C9","CA","CB","CC","CD","CE","CF",
|
||||
"D0","D1","D2","D3","D4","D5","D6","D7","D8","D9","DA","DB","DC","DD","DE","DF",
|
||||
"E0","E1","E2","E3","E4","E5","E6","E7","E8","E9","EA","EB","EC","ED","EE","EF",
|
||||
"F0","F1","F2","F3","F4","F5","F6","F7","F8","F9","FA","FB","FC","FD","FE","FF"
|
||||
};
|
||||
private final static byte[] val = {
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F
|
||||
};
|
||||
public static String escape(String s) {
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
if(s !=null && !"".equals(s)){
|
||||
int len = s.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int ch = s.charAt(i);
|
||||
if (ch == ' ') { // space : map to '+'
|
||||
sbuf.append('+');
|
||||
} else if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if ('a' <= ch && ch <= 'z') { // 'a'..'z' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if ('0' <= ch && ch<='9'){
|
||||
// '0'..'9' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if (ch == '-' || ch == '_' // unreserved : as it was
|
||||
|| ch == '.' || ch == '!'
|
||||
|| ch == '~' || ch == '*'
|
||||
|| ch == '\'' || ch == '('
|
||||
|| ch == ')') {
|
||||
sbuf.append((char)ch);
|
||||
} else if (ch <= 0x007F) { // other ASCII : map to %XX
|
||||
sbuf.append('%');
|
||||
sbuf.append(hex[ch]);
|
||||
} else { // unicode : map to %uXXXX
|
||||
sbuf.append('%');
|
||||
sbuf.append('u');
|
||||
sbuf.append(hex[(ch >>> 8)]);
|
||||
sbuf.append(hex[(0x00FF & ch)]);
|
||||
}
|
||||
} }
|
||||
return sbuf.toString();
|
||||
}
|
||||
public static String unescape(String s) {
|
||||
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
if(null !=s && !"".equals(s)){
|
||||
int i = 0;
|
||||
int len = s.length();
|
||||
while (i < len) {
|
||||
int ch = s.charAt(i);
|
||||
if (ch == '+') { // + : map to ' '
|
||||
sbuf.append(' ');
|
||||
} else if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if ('a' <= ch && ch <= 'z') { // 'a'..'z' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if ('0' <= ch && ch <= '9') { // '0'..'9' : as it was
|
||||
sbuf.append((char)ch);
|
||||
} else if (ch == '-' || ch == '_' // unreserved : as it was
|
||||
|| ch == '.' || ch == '!'
|
||||
|| ch == '~' || ch == '*'
|
||||
|| ch == '\'' || ch == '('
|
||||
|| ch == ')') {
|
||||
sbuf.append((char)ch);
|
||||
} else if (ch == '%') {
|
||||
int cint = 0;
|
||||
if ('u' != s.charAt(i+1)) { // %XX : map to ascii(XX)
|
||||
cint = (cint << 4) | val[s.charAt(i+1)];
|
||||
cint = (cint << 4) | val[s.charAt(i+2)];
|
||||
i+=2;
|
||||
} else { // %uXXXX : map to unicode(XXXX)
|
||||
cint = (cint << 4) | val[s.charAt(i+2)];
|
||||
cint = (cint << 4) | val[s.charAt(i+3)];
|
||||
cint = (cint << 4) | val[s.charAt(i+4)];
|
||||
cint = (cint << 4) | val[s.charAt(i+5)];
|
||||
i+=5;
|
||||
}
|
||||
sbuf.append((char)cint);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
String str = Escape.escape("{\"jhraccount\":\"testa\",\"jhrpassword\":\"1111\"}");
|
||||
System.out.println(str);
|
||||
System.out.println(Escape.unescape("%257B%250A++%2522teacherkey%2522+%253A+%25222014122718143719141%2522%252C%250A++%2522schoolkey%2522+%253A+%25222014122718143657297%2522%252C%250A++%2522babykey%2522+%253A+%25222014122920394364557%2522%252C%250A++%2522qdtype%2522+%253A+0%250A%257D"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
210
src/main/java/com/util/NetUtil.java
Normal file
210
src/main/java/com/util/NetUtil.java
Normal file
@@ -0,0 +1,210 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NetUtil {
|
||||
public static final String DEF_CHATSET = "UTF-8";
|
||||
public static final int DEF_CONN_TIMEOUT = 30000;
|
||||
public static final int DEF_READ_TIMEOUT = 30000;
|
||||
public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param strUrl 请求地址
|
||||
* @param params 请求参数
|
||||
* @param method 请求方法
|
||||
* @return 网络请求字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String net(String strUrl, final Map<String, Object> params,String method) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader reader = null;
|
||||
String rs = null;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(method==null || method.equals("GET")){
|
||||
if(params!=null&&"".equals(params)){
|
||||
strUrl = strUrl+"?"+urlencode(params);
|
||||
}
|
||||
|
||||
}
|
||||
// System.out.println("net_url:"+strUrl);
|
||||
// String last = strUrl.substring(strUrl.length()-1, strUrl.length());
|
||||
// if("&".equals(last)){
|
||||
// strUrl = strUrl.substring(0, strUrl.length()-1);
|
||||
// }
|
||||
URL url = new URL(strUrl);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
if(method==null || method.equals("GET")){
|
||||
conn.setRequestMethod("GET");
|
||||
}else{
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
}
|
||||
conn.setRequestProperty("User-agent", userAgent);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(DEF_CONN_TIMEOUT);
|
||||
conn.setReadTimeout(DEF_READ_TIMEOUT);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
// if (params!= null && method.equals("POST")) {
|
||||
// try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
|
||||
// out.writeBytes(urlencode(params));
|
||||
// }
|
||||
// }
|
||||
InputStream is = conn.getInputStream();
|
||||
reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
|
||||
String strRead = null;
|
||||
while ((strRead = reader.readLine()) != null) {
|
||||
sb.append(strRead);
|
||||
}
|
||||
rs = sb.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定URL发送GET方法的请求
|
||||
*
|
||||
* @param url
|
||||
* 发送请求的URL
|
||||
* @param param
|
||||
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||
* @return URL 所代表远程资源的响应结果
|
||||
*/
|
||||
public static String sendGet(String url, String param) {
|
||||
String result = "";
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
String urlNameString = url + "?" + param;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
connection.setRequestProperty("accept", "*/*");
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
connection.setRequestProperty("user-agent",
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
// 建立实际的连接
|
||||
connection.connect();
|
||||
// 获取所有响应头字段
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(
|
||||
connection.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送GET请求出现异常!" + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输入流
|
||||
finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定 URL 发送POST方法的请求
|
||||
*
|
||||
* @param url
|
||||
* 发送请求的 URL
|
||||
* @param param
|
||||
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||
* @return 所代表远程资源的响应结果
|
||||
*/
|
||||
public static String sendPost(String url, String param) {
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
String result = "";
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "*/*");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
conn.setRequestProperty("user-agent",
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 发送请求参数
|
||||
out.print(param);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送 POST 请求出现异常!"+e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally{
|
||||
try{
|
||||
if(out!=null){
|
||||
out.close();
|
||||
}
|
||||
if(in!=null){
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch(IOException ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//将map型转为请求参数型
|
||||
public static String urlencode(Map<String, ?> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, ?> i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
155
src/main/java/com/util/NewFieldUtileTools.java
Normal file
155
src/main/java/com/util/NewFieldUtileTools.java
Normal file
@@ -0,0 +1,155 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class NewFieldUtileTools {
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
* @param filePath
|
||||
* @param fileName
|
||||
* @param fileContent
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public static boolean fileOperation(String filePath, String fileName,String fileContent){
|
||||
boolean sign = false;
|
||||
String pathTemp = filePath + "\\" + fileName;
|
||||
File file = new File(pathTemp);
|
||||
File file2 = new File(filePath);
|
||||
file2.mkdirs();
|
||||
try {
|
||||
// 文件不存在
|
||||
if (!file.exists()) {
|
||||
|
||||
sign = createFile(pathTemp);// 创建文件
|
||||
if (sign) {// 文件创建成功
|
||||
writeFile(pathTemp, fileContent);// 写入内容
|
||||
}
|
||||
} else {
|
||||
sign = deleteFile(pathTemp);// 删除文件
|
||||
sign = createFile(pathTemp);// 创建文件
|
||||
if (sign) {// 文件创建成功
|
||||
writeFile(pathTemp, fileContent);// 写入内容
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sign;
|
||||
}
|
||||
/**
|
||||
* 创建文件
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static boolean createFile(String name) throws IOException {
|
||||
boolean flag = false;
|
||||
File filename = new File(name);
|
||||
if (!filename.exists()) {
|
||||
filename.createNewFile();
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写文件
|
||||
*
|
||||
* @param newStr
|
||||
* 新内容
|
||||
* @throws IOException
|
||||
*/
|
||||
public static boolean writeFile(String filePath, String newStr)
|
||||
throws IOException {
|
||||
// 先读取原有文件内容,然后进行写入操作
|
||||
boolean flag = false;
|
||||
String filein = newStr + "\r\n";
|
||||
// String str = new String(filein.getBytes("UTF-8"),"UTF-8");
|
||||
String temp = "";
|
||||
FileInputStream fis = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
FileOutputStream fos = null;
|
||||
// PrintWriter pw = null;
|
||||
Writer pw = null;
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
// 将文件读入输入流
|
||||
fis = new FileInputStream(file);
|
||||
isr = new InputStreamReader(fis, "utf-8");
|
||||
br = new BufferedReader(isr);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
// // 文件路径
|
||||
// File file = new File(filePath);
|
||||
// // 将文件读入输入流
|
||||
//
|
||||
// isr = new InputStreamReader(new FileInputStream(file),"utf-8");
|
||||
// br = new BufferedReader(isr);
|
||||
// StringBuffer buf = new StringBuffer();
|
||||
/**
|
||||
* File f=new File(rawfilename); if(f.exists()) { BufferedReader
|
||||
* br=null; try { String line; InputStreamReader read = new
|
||||
* InputStreamReader(new FileInputStream(f),"utf-8"); br=new
|
||||
* BufferedReader(read);
|
||||
*/
|
||||
// 保存该文件原有的内容
|
||||
for (int i = 1; (temp = br.readLine()) != null; i++) {
|
||||
buf = buf.append(temp);
|
||||
buf = buf.append(System.getProperty("line.separator"));
|
||||
}
|
||||
buf.append(filein);
|
||||
fos = new FileOutputStream(file);
|
||||
pw = new OutputStreamWriter(fos, "utf-8");
|
||||
pw.write(buf.toString());
|
||||
pw.flush();
|
||||
flag = true;
|
||||
} catch (IOException e1) {
|
||||
throw e1;
|
||||
} finally {
|
||||
if (pw != null) {
|
||||
pw.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
if (br != null) {
|
||||
br.close();
|
||||
}
|
||||
if (isr != null) {
|
||||
isr.close();
|
||||
}
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个文件
|
||||
*
|
||||
* @param fileName
|
||||
* 被删除文件的文件名
|
||||
* @return 单个文件删除成功返回true,否则返回false
|
||||
*/
|
||||
public static boolean deleteFile(String fileName) {
|
||||
boolean isSuccess = false;
|
||||
File file = new File(fileName);
|
||||
if (file.isFile() && file.exists()) {
|
||||
file.delete();
|
||||
isSuccess = true;
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
}
|
||||
278
src/main/java/com/util/OfficeUtil.java
Normal file
278
src/main/java/com/util/OfficeUtil.java
Normal file
@@ -0,0 +1,278 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class OfficeUtil {
|
||||
|
||||
/********************************************************* xls *************************************************************/
|
||||
|
||||
/**
|
||||
* 写Excel并下载针对.xls
|
||||
*
|
||||
*/
|
||||
public boolean writeAndDownExcelToXLS(HttpServletRequest request,HttpServletResponse response, List list, String[] titles,
|
||||
HSSFWorkbook workbook, HSSFSheet sheet, String filepath) {
|
||||
boolean flag = true;
|
||||
if (null!=list && list.size()>0) {
|
||||
try {
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
HSSFRow row = sheet.createRow(i);
|
||||
WriteExcelCellContextToXLS(workbook, row,i,titles[i]);
|
||||
}
|
||||
for (int j = 1; j <= list.size(); j++) {
|
||||
Object[] object = object = (Object[]) list.get(j - 1);
|
||||
HSSFRow row = sheet.createRow(j);
|
||||
for (int n = 0; n < object.length; n++) {
|
||||
WriteExcelCellContextToXLS(workbook,row,n,object[n] == null ? "" : UtilTools.delHTMLTag(object[n].toString()));
|
||||
}
|
||||
}
|
||||
flag = CreateExcel(filepath, workbook);
|
||||
if (flag) {
|
||||
flag = UtilTools.downFile(response, filepath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
flag = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写Excel内容针对.xls且对标题行加样式
|
||||
*
|
||||
*/
|
||||
public static void WriteExcelCellContextToXLS(HSSFWorkbook workbook,HSSFRow row,int cellindex,String content) {
|
||||
HSSFCell cell = row.createCell((short) cellindex);
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
|
||||
cell.setCellValue(content);
|
||||
//加样式
|
||||
HSSFCellStyle style = workbook.createCellStyle();
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontHeightInPoints((short) 11);// 字号
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);// 加粗
|
||||
font.setColor(HSSFFont.COLOR_RED);// 颜色
|
||||
style.setFont(font);
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
|
||||
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写Excel内容针对.xls
|
||||
*
|
||||
*/
|
||||
public static void WriteExcelCellContextToXLS(HSSFRow row,int cellindex,String content) {
|
||||
HSSFCell cell = row.createCell((short) cellindex);
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
|
||||
cell.setCellValue(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取.xls Excel单元格的值
|
||||
*
|
||||
*/
|
||||
public static Object getCellResultToXLS(HSSFRow row, int cellnum) {
|
||||
HSSFCell cell = row.getCell((short) cellnum);
|
||||
Object value = null;
|
||||
DecimalFormat df = new DecimalFormat("0");// 格式化 number String 字符
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化日期字符串
|
||||
DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字
|
||||
if (null != cell) {
|
||||
switch (cell.getCellType()) {
|
||||
case HSSFCell.CELL_TYPE_STRING:
|
||||
value = cell.getStringCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_FORMULA:
|
||||
try {
|
||||
value=cell.getNumericCellValue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
value ="";
|
||||
}
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_NUMERIC:
|
||||
/*if ("@".equals(cell.getCellStyle().getDataFormat())) {
|
||||
value = df.format(cell.getNumericCellValue());
|
||||
} else if ("General".equals(cell.getCellStyle().getDataFormat())) {
|
||||
value = nf.format(cell.getNumericCellValue());
|
||||
} else {
|
||||
value = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
|
||||
}*/
|
||||
if (HSSFDateUtil.isCellDateFormatted(cell)) { //日期
|
||||
value = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
|
||||
} else { // 纯数字
|
||||
value = df.format(cell.getNumericCellValue());
|
||||
}
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_BOOLEAN:
|
||||
value = cell.getBooleanCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_BLANK:
|
||||
value = "";
|
||||
break;
|
||||
default:
|
||||
value = cell.toString();
|
||||
}
|
||||
} else {
|
||||
value = "";
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
/********************************************************* xlsx *************************************************************/
|
||||
|
||||
/**
|
||||
* 写Excel内容针对.xlsx且对标题行加样式
|
||||
*
|
||||
*/
|
||||
public static void WriteExcelCellContextToXLSX(XSSFWorkbook workbook,XSSFRow row,int cellindex,String content) {
|
||||
XSSFCell cell = row.createCell(cellindex);
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
cell.setCellValue(content);
|
||||
//加样式
|
||||
XSSFCellStyle style = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
||||
font.setColor(HSSFFont.COLOR_RED);
|
||||
style.setFont(font);
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写Excel内容针对.xlsx
|
||||
*
|
||||
*/
|
||||
public static void WriteExcelCellContextToXLSX(XSSFRow row, int cellindex,String content) {
|
||||
XSSFCell cell = row.createCell(cellindex);
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
cell.setCellValue(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取.xlsx Excel单元格的值
|
||||
*
|
||||
*/
|
||||
public static Object getExcelResultToXLSX(XSSFRow row, int cellnum) {
|
||||
Object value = null;
|
||||
XSSFCell cell = row.getCell(cellnum);
|
||||
DecimalFormat df = new DecimalFormat("0");// 格式化 number String 字符
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化日期字符串
|
||||
DecimalFormat ndf = new DecimalFormat("0.00");// 格式化数字
|
||||
if (null != cell) {
|
||||
switch (cell.getCellType()) {
|
||||
case XSSFCell.CELL_TYPE_STRING:
|
||||
value = cell.getStringCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_NUMERIC:
|
||||
if ("@".equals(cell.getCellStyle().getDataFormatString())) {
|
||||
value = df.format(cell.getNumericCellValue());
|
||||
} else if ("General".equals(cell.getCellStyle().getDataFormatString())) {
|
||||
value = ndf.format(cell.getNumericCellValue());
|
||||
} else {
|
||||
value = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
|
||||
}
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_BOOLEAN:
|
||||
value = cell.getBooleanCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_BLANK:
|
||||
value = "";
|
||||
break;
|
||||
default:
|
||||
value = cell.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(value==null)value="";
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断sheet行标题与指定标题是否一至
|
||||
*/
|
||||
public static boolean sheetRowTitleToXlSX(XSSFSheet sheet,String[] titles){
|
||||
boolean flag=true;
|
||||
XSSFRow row=sheet.getRow(0);
|
||||
for(int i=0;i<titles.length;i++){
|
||||
String rt=getExcelResultToXLSX(row, i).toString();
|
||||
if(!titles[i].equals(rt)){
|
||||
flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* 生成Excel
|
||||
*
|
||||
*/
|
||||
public static boolean CreateExcel(String filepath, Workbook workbook) {
|
||||
boolean flag = true;
|
||||
try {
|
||||
File file = new File(filepath);
|
||||
if(!file.getParentFile().exists()){
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
OutputStream os = new FileOutputStream(filepath);
|
||||
try {
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
flag = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
flag = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
153
src/main/java/com/util/OutCall.java
Normal file
153
src/main/java/com/util/OutCall.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.util;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-9-18 上午11:31:04
|
||||
* 类说明
|
||||
*/
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
*短信API服务调用示例代码 - 聚合数据
|
||||
*在线接口文档:http://www.juhe.cn/docs/54
|
||||
**/
|
||||
|
||||
public class OutCall {
|
||||
public static final String DEF_CHATSET = "UTF-8";
|
||||
public static final int DEF_CONN_TIMEOUT = 30000;
|
||||
public static final int DEF_READ_TIMEOUT = 30000;
|
||||
public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
|
||||
public static String url ="http://121.40.120.141/app";
|
||||
|
||||
//2.外呼
|
||||
public static boolean getTalk(String phoneno,String zxno,String key){
|
||||
boolean sign = false;
|
||||
String result =null;
|
||||
Map<String, Object> params = new HashMap<String, Object>();//请求参数
|
||||
params.put("Action","Dialout");//命令名称,外呼接口中固定名称为Dialout
|
||||
params.put("ActionID",key);//随机码,用户用来标识请求的操作,服务器返回的Response中会带有对应Action的ActionID;在通话事件中会带有该字段;该字段最大长度是40个字节
|
||||
params.put("Account","N00000002010");
|
||||
params.put("Exten",phoneno);//被叫号码
|
||||
params.put("FromExten",zxno);//坐席工号
|
||||
params.put("PBX", "sh.ali.1.5");
|
||||
params.put("ExtenType", "gateway");//外呼时强制座席使用该接听方式。可选参数。正常情况下调用外呼接口不需传此字段,座席默认使用登陆呼叫中心的接听方式外呼。
|
||||
//如有特殊需要,例如:座席不登陆系统发起外呼,需要传此字段。
|
||||
//Local为“手机”
|
||||
//sip为“软电话”
|
||||
//gateway为“语音网关”
|
||||
|
||||
try {
|
||||
result =net(url, params, "GET");
|
||||
System.out.println("---"+result);
|
||||
JSONObject object = JSONObject.fromObject(result);
|
||||
sign = object.getBoolean("Succeed");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sign = false;
|
||||
}
|
||||
return sign;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getTalk("13764935808","8003",RequestUtil.getid(6)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param strUrl 请求地址
|
||||
* @param params 请求参数
|
||||
* @param method 请求方法
|
||||
* @return 网络请求字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String net(String strUrl, final Map<String, Object> params,String method) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader reader = null;
|
||||
String rs = null;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(method==null || method.equals("GET")){
|
||||
strUrl = strUrl+"?"+urlencode(params);
|
||||
}
|
||||
// String last = strUrl.substring(strUrl.length()-1, strUrl.length());
|
||||
// if("&".equals(last)){
|
||||
// strUrl = strUrl.substring(0, strUrl.length()-1);
|
||||
// }
|
||||
URL url = new URL(strUrl);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
if(method==null || method.equals("GET")){
|
||||
conn.setRequestMethod("GET");
|
||||
}else{
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
}
|
||||
conn.setRequestProperty("User-agent", userAgent);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(DEF_CONN_TIMEOUT);
|
||||
conn.setReadTimeout(DEF_READ_TIMEOUT);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
// if (params!= null && method.equals("POST")) {
|
||||
// try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
|
||||
// out.writeBytes(urlencode(params));
|
||||
// }
|
||||
// }
|
||||
InputStream is = conn.getInputStream();
|
||||
reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
|
||||
String strRead = null;
|
||||
while ((strRead = reader.readLine()) != null) {
|
||||
sb.append(strRead);
|
||||
}
|
||||
rs = sb.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
//将map型转为请求参数型
|
||||
public static String urlencode(Map<String, ?> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, ?> i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
102
src/main/java/com/util/PinYin2Abbreviation.java
Normal file
102
src/main/java/com/util/PinYin2Abbreviation.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.util;
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-10-6 下午2:03:37
|
||||
* 类说明:获取中文首字母
|
||||
*/
|
||||
public class PinYin2Abbreviation {
|
||||
|
||||
// 简体中文的编码范围从B0A1(45217)一直到F7FE(63486)
|
||||
private static int BEGIN = 45217;
|
||||
private static int END = 63486;
|
||||
|
||||
// 按照声 母表示,这个表是在GB2312中的出现的第一个汉字,也就是说“啊”是代表首字母a的第一个汉字。
|
||||
// i, u, v都不做声母, 自定规则跟随前面的字母
|
||||
private static char[] chartable = { '啊', '芭', '擦', '搭', '蛾', '发', '噶', '哈', '哈', '击', '喀', '垃', '妈', '拿', '哦', '啪', '期', '然', '撒', '塌', '塌', '塌', '挖', '昔', '压', '匝', };
|
||||
|
||||
// 二十六个字母区间对应二十七个端点
|
||||
// GB2312码汉字区间十进制表示
|
||||
private static int[] table = new int[27];
|
||||
|
||||
// 对应首字母区间表
|
||||
private static char[] initialtable = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 't', 't', 'w', 'x', 'y', 'z', };
|
||||
|
||||
// 初始化
|
||||
static {
|
||||
for (int i = 0; i < 26; i++) {
|
||||
table[i] = gbValue(chartable[i]);// 得到GB2312码的首字母区间端点表,十进制。
|
||||
}
|
||||
table[26] = END;// 区间表结尾
|
||||
}
|
||||
|
||||
// ------------------------public方法区------------------------
|
||||
// 根据一个包含汉字的字符串返回一个汉字拼音首字母的字符串 最重要的一个方法,思路如下:一个个字符读入、判断、输出
|
||||
|
||||
public static String cn2py(String SourceStr) {
|
||||
String Result = "";
|
||||
int StrLength = SourceStr.length();
|
||||
int i;
|
||||
try {
|
||||
for (i = 0; i < StrLength; i++) {
|
||||
Result += Char2Initial(SourceStr.charAt(i));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Result = "";
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
// ------------------------private方法区------------------------
|
||||
/**
|
||||
* 输入字符,得到他的声母,英文字母返回对应的大写字母,其他非简体汉字返回 '0' *
|
||||
*/
|
||||
private static char Char2Initial(char ch) {
|
||||
// 对英文字母的处理:小写字母转换为大写,大写的直接返回
|
||||
if (ch >= 'a' && ch <= 'z') {
|
||||
return (char) (ch - 'a' + 'A');
|
||||
}
|
||||
if (ch >= 'A' && ch <= 'Z') {
|
||||
return ch;
|
||||
}
|
||||
// 对非英文字母的处理:转化为首字母,然后判断是否在码表范围内,
|
||||
// 若不是,则直接返回。
|
||||
// 若是,则在码表内的进行判断。
|
||||
int gb = gbValue(ch);// 汉字转换首字母
|
||||
if ((gb < BEGIN) || (gb > END))// 在码表区间之前,直接返回
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < 26; i++) {// 判断匹配码表区间,匹配到就break,判断区间形如“[,)”
|
||||
if ((gb >= table[i]) && (gb < table[i + 1])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gb == END) {// 补上GB2312区间最右端
|
||||
i = 25;
|
||||
}
|
||||
return initialtable[i]; // 在码表区间中,返回首字母
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出汉字的编码 cn 汉字
|
||||
*/
|
||||
private static int gbValue(char ch) {// 将一个汉字(GB2312)转换为十进制表示。
|
||||
String str = new String();
|
||||
str += ch;
|
||||
try {
|
||||
byte[] bytes = str.getBytes("GB2312");
|
||||
if (bytes.length < 2) {
|
||||
return 0;
|
||||
}
|
||||
return (bytes[0] << 8 & 0xff00) + (bytes[1] & 0xff);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(cn2py("宝").toUpperCase());
|
||||
}
|
||||
}
|
||||
141
src/main/java/com/util/ReadExcel.java
Normal file
141
src/main/java/com/util/ReadExcel.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package com.util;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import java.io.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by 16094 on 2017/8/24.
|
||||
*/
|
||||
public class ReadExcel {
|
||||
|
||||
private Workbook workbook;
|
||||
|
||||
private static String desktopPath = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath();
|
||||
|
||||
|
||||
public ReadExcel(File excelFile) throws Exception {
|
||||
workbook = WorkbookFactory.create(new FileInputStream(excelFile));
|
||||
}
|
||||
|
||||
public List<String> getData(int index) {
|
||||
|
||||
try {
|
||||
List result = new ArrayList();
|
||||
int rowSize = 0;
|
||||
Cell cell = null;
|
||||
int numberOfSheets = Math.min(workbook.getNumberOfSheets(), index);
|
||||
for (int sheetIndex = 0; sheetIndex < numberOfSheets; sheetIndex++) {
|
||||
Sheet sheetAt = workbook.getSheetAt(sheetIndex);
|
||||
for (int rowIndex = 0; rowIndex <= sheetAt.getLastRowNum(); rowIndex++) {
|
||||
Row row = sheetAt.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
int tempRowSize = row.getLastCellNum() + 1;
|
||||
if (tempRowSize > rowSize) {
|
||||
rowSize = tempRowSize;
|
||||
}
|
||||
List mapList = new ArrayList();
|
||||
// mapList.clear();
|
||||
//boolean hasValue = false;
|
||||
for (short columnIndex = 0; columnIndex <= row.getLastCellNum(); columnIndex = (short) (columnIndex + 1)) {
|
||||
String value = "";
|
||||
// String key = "";
|
||||
cell = row.getCell(columnIndex);
|
||||
if (cell != null) {
|
||||
switch (cell.getCellType()) {
|
||||
case 1:
|
||||
value = cell.getStringCellValue();
|
||||
// key = "String";
|
||||
break;
|
||||
case 0:
|
||||
if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
||||
Date date = cell.getDateCellValue();
|
||||
if (date != null)
|
||||
value = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
||||
else {
|
||||
value = "";
|
||||
}
|
||||
// key = "Date";
|
||||
} else {
|
||||
value = new DecimalFormat("0").format(cell.getNumericCellValue());
|
||||
// key = "Integer";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!cell.getStringCellValue().equals(""))
|
||||
value = cell.getStringCellValue();
|
||||
else {
|
||||
value = cell.getNumericCellValue() + "";
|
||||
}
|
||||
// key = "String";
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 5:
|
||||
value = "";
|
||||
// key = "";
|
||||
break;
|
||||
case 4:
|
||||
value = cell.getBooleanCellValue() == true ? "Y" : "N";
|
||||
//key = "boolean";
|
||||
break;
|
||||
default:
|
||||
value = "";
|
||||
//key = "";
|
||||
}
|
||||
}
|
||||
if (value == null || value.equals("")) {
|
||||
break;
|
||||
}
|
||||
if ((columnIndex == 0) && (value.trim().equals(""))) {
|
||||
break;
|
||||
}
|
||||
//stringStringMap.put(rightTrim(key), );
|
||||
mapList.add(rightTrim(value));
|
||||
// hasValue = true;
|
||||
}
|
||||
result.add(mapList);
|
||||
// if (hasValue) {
|
||||
// result.add(mapList);
|
||||
// }
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String rightTrim(String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
int length = str.length();
|
||||
for (int i = length - 1; (i >= 0) &&
|
||||
(str.charAt(i) == ' '); i--) {
|
||||
length--;
|
||||
}
|
||||
return str.substring(0, length);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File(desktopPath + "/Outcomes.xlsx");
|
||||
List datas = new ReadExcel(file).getData(1);
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
List listinfo = (List) datas.get(i);
|
||||
for (int j = 0; j < listinfo.size(); j++) {
|
||||
System.out.print(listinfo.get(j) + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
109
src/main/java/com/util/ReadExcel2003.java
Normal file
109
src/main/java/com/util/ReadExcel2003.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
/**
|
||||
* 解析excel2003
|
||||
*/
|
||||
public class ReadExcel2003{
|
||||
|
||||
private HSSFWorkbook workbook ;
|
||||
public ReadExcel2003(File excelFile) throws FileNotFoundException, IOException{
|
||||
workbook = new HSSFWorkbook(new FileInputStream(excelFile));
|
||||
}
|
||||
|
||||
/**
|
||||
*读取所有列
|
||||
*/
|
||||
public List<List> getDatasInSheetarrall(int sheetNumber) throws FileNotFoundException, IOException{
|
||||
List result = new ArrayList();
|
||||
|
||||
//获得指定的表
|
||||
HSSFSheet sheet = workbook.getSheetAt(sheetNumber);
|
||||
//获得数据总行数
|
||||
int rowCount = sheet.getLastRowNum();
|
||||
if (rowCount < 1) {
|
||||
return result;
|
||||
}
|
||||
//逐行读取数据
|
||||
for (int rowIndex = 0; rowIndex <= rowCount; rowIndex++) {
|
||||
//获得行对象
|
||||
HSSFRow row = sheet.getRow(rowIndex);
|
||||
if (row != null) {
|
||||
List list=new ArrayList();
|
||||
int columnCount = row.getLastCellNum();
|
||||
//读取所有的列
|
||||
for (int i = 0; i <columnCount; i++) {
|
||||
//获得本行中单元格的个数
|
||||
//获得本行中各单元格中的数据
|
||||
HSSFCell cell = row.getCell(Short.parseShort(i+""));
|
||||
//获得指定单元格中数据
|
||||
Object cellStr = this.getCellString(cell);
|
||||
if(null!=cellStr){
|
||||
list.add(cellStr.toString());
|
||||
}else{
|
||||
list.add("");
|
||||
}
|
||||
}
|
||||
result.add(list);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 获得单元格中的内容
|
||||
* @param cell
|
||||
* @return
|
||||
*/
|
||||
protected Object getCellString(HSSFCell cell){
|
||||
Object result = null;
|
||||
if (cell != null) {
|
||||
int cellType = cell.getCellType();
|
||||
switch(cellType){
|
||||
case HSSFCell.CELL_TYPE_STRING :
|
||||
result = cell.getStringCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_NUMERIC:
|
||||
result=cell.getNumericCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_FORMULA:
|
||||
result = cell.getNumericCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_ERROR:
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_BOOLEAN:
|
||||
result=cell.getBooleanCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_BLANK:
|
||||
result=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File("C:\\Users\\Administrator\\Desktop\\新建 Microsoft Excel 工作表.xls");
|
||||
ReadExcel2003 parser = new ReadExcel2003(file);
|
||||
List<List> datas = parser.getDatasInSheetarrall(0);
|
||||
boolean b=false;
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
List listinfo = (List) datas.get(i);
|
||||
for (int j = 0; j < listinfo.size(); j++) {
|
||||
System.out.print(listinfo.get(j) + " ");
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
112
src/main/java/com/util/ReadExcel2007.java
Normal file
112
src/main/java/com/util/ReadExcel2007.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
* 解析excel2007
|
||||
*/
|
||||
public class ReadExcel2007 {
|
||||
|
||||
private XSSFWorkbook workbook;
|
||||
|
||||
public ReadExcel2007(File excelFile)throws FileNotFoundException, IOException {
|
||||
workbook = new XSSFWorkbook(new FileInputStream(excelFile));
|
||||
}
|
||||
|
||||
/**
|
||||
*读取所有列
|
||||
*/
|
||||
public List<List> getDatasInSheetarrall(int sheetNumber)
|
||||
throws FileNotFoundException, IOException {
|
||||
List result = new ArrayList();
|
||||
|
||||
//获得指定的表
|
||||
XSSFSheet sheet = workbook.getSheetAt(sheetNumber);
|
||||
//获得数据总行数
|
||||
int rowCount = sheet.getLastRowNum();
|
||||
if (rowCount < 1) {
|
||||
return result;
|
||||
}
|
||||
//逐行读取数据
|
||||
for (int rowIndex = 0; rowIndex <= rowCount; rowIndex++) {
|
||||
//获得行对象
|
||||
XSSFRow row = sheet.getRow(rowIndex);
|
||||
if (row != null) {
|
||||
List list = new ArrayList();
|
||||
int columnCount = row.getLastCellNum();
|
||||
//读取所有的列
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
//获得本行中单元格的个数
|
||||
//获得本行中各单元格中的数据
|
||||
XSSFCell cell = row.getCell(Short.parseShort(i + ""));
|
||||
//获得指定单元格中数据
|
||||
Object cellStr = this.getCellString(cell);
|
||||
if (null != cellStr) {
|
||||
list.add(cellStr.toString().trim());
|
||||
} else {
|
||||
list.add("");
|
||||
}
|
||||
}
|
||||
result.add(list);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得单元格中的内容
|
||||
* @param cell
|
||||
* @return
|
||||
*/
|
||||
protected Object getCellString(XSSFCell cell) {
|
||||
Object result = null;
|
||||
if (cell != null) {
|
||||
int cellType = cell.getCellType();
|
||||
switch (cellType) {
|
||||
case XSSFCell.CELL_TYPE_STRING:
|
||||
result = cell.getStringCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_NUMERIC:
|
||||
result = cell.getNumericCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_FORMULA:
|
||||
result = cell.getNumericCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_ERROR:
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_BOOLEAN:
|
||||
result = cell.getBooleanCellValue();
|
||||
break;
|
||||
case XSSFCell.CELL_TYPE_BLANK:
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File("C:\\Users\\Administrator\\Desktop\\金钥匙\\测试清单.xlsx");
|
||||
ReadExcel2007 parser3 = new ReadExcel2007(file);
|
||||
List<List> datas = parser3.getDatasInSheetarrall(0);
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
List listinfo = (List) datas.get(i);
|
||||
for (int j = 0; j < listinfo.size(); j++) {
|
||||
System.out.print(listinfo.get(j) + " ");
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
//XMLEventFactory
|
||||
//C:\java\MyEclipse 6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.0.0.zmyeclipse60020070820\data\libraryset\EE_5
|
||||
}
|
||||
|
||||
}
|
||||
139
src/main/java/com/util/RequestMessage.java
Normal file
139
src/main/java/com/util/RequestMessage.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-9-29 下午4:56:12
|
||||
* 类说明
|
||||
*/
|
||||
public class RequestMessage {
|
||||
public static final String DEF_CHATSET = "UTF-8";
|
||||
public static final int DEF_CONN_TIMEOUT = 30000;
|
||||
public static final int DEF_READ_TIMEOUT = 30000;
|
||||
public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
|
||||
//配置您申请的KEY
|
||||
public static final String APPKEY ="3bbd4eebe311f16af14c8f38dfa927f1";
|
||||
//模板编号
|
||||
// public static String tpl_id= "4027";
|
||||
//返回格式
|
||||
public static String dtype = "json";
|
||||
public static String url ="http://v.juhe.cn/sms/send";
|
||||
|
||||
//2.发送短信
|
||||
public static boolean SendMessage(String phoneno,String code,String tpl_id){
|
||||
boolean sign = false;
|
||||
String result =null;
|
||||
Map<String, Object> params = new HashMap<String, Object>();//请求参数
|
||||
params.put("mobile",phoneno);//接收短信的手机号码
|
||||
params.put("tpl_id",tpl_id);//短信模板ID,请参考个人中心短信模板设置
|
||||
//"#customername#="+code+"&#employeeno#="+8004+""
|
||||
params.put("tpl_value",code);
|
||||
//变量名和变量值对。如果你的变量名或者变量值中带有#&=中的任意一个特殊符号,请先分别进行urlencode编码后再传递,<a href="http://www.juhe.cn/news/index/id/50" target="_blank">详细说明></a>
|
||||
params.put("key",APPKEY);//应用APPKEY(应用详细页查询)
|
||||
params.put("dtype",dtype);//返回数据的格式,xml或json,默认json
|
||||
|
||||
try {
|
||||
result =net(url, params, "GET");
|
||||
// System.out.println("---"+result);
|
||||
JSONObject object = JSONObject.fromObject(result);
|
||||
if(object.getInt("error_code")==0){
|
||||
// System.out.println(object.get("result"));
|
||||
sign = true;
|
||||
}else{
|
||||
// System.out.println(object.get("error_code")+":"+object.get("reason"));
|
||||
sign = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sign = false;
|
||||
}
|
||||
return sign;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
//System.out.println(SendMessage("17717522592","收到请回复。。。。。"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param strUrl 请求地址
|
||||
* @param params 请求参数
|
||||
* @param method 请求方法
|
||||
* @return 网络请求字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String net(String strUrl, final Map<String, Object> params,String method) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader reader = null;
|
||||
String rs = null;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(method==null || method.equals("GET")){
|
||||
strUrl = strUrl+"?"+urlencode(params);
|
||||
}
|
||||
URL url = new URL(strUrl);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
if(method==null || method.equals("GET")){
|
||||
conn.setRequestMethod("GET");
|
||||
}else{
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
}
|
||||
conn.setRequestProperty("User-agent", userAgent);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(DEF_CONN_TIMEOUT);
|
||||
conn.setReadTimeout(DEF_READ_TIMEOUT);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
// if (params!= null && method.equals("POST")) {
|
||||
// try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
|
||||
// out.writeBytes(urlencode(params));
|
||||
// }
|
||||
// }
|
||||
InputStream is = conn.getInputStream();
|
||||
reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
|
||||
String strRead = null;
|
||||
while ((strRead = reader.readLine()) != null) {
|
||||
sb.append(strRead);
|
||||
}
|
||||
rs = sb.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
//将map型转为请求参数型
|
||||
public static String urlencode(Map<String, ?> data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, ?> i : data.entrySet()) {
|
||||
try {
|
||||
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
1407
src/main/java/com/util/RequestUtil.java
Normal file
1407
src/main/java/com/util/RequestUtil.java
Normal file
File diff suppressed because it is too large
Load Diff
57
src/main/java/com/util/SendMessage.java
Normal file
57
src/main/java/com/util/SendMessage.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-9-1 下午3:36:20
|
||||
* 类说明
|
||||
*/
|
||||
public class SendMessage {
|
||||
private final static String action="interfaceSms";
|
||||
private final static String account = "N00000002010";
|
||||
private final static String password = "bvff334f3x5ids";
|
||||
private final static String sign = "太e车";
|
||||
private final static String md5="81f0e1f0-32df-11e3-a2e6-1d21429e5f46";
|
||||
public static boolean sendcode(String phone,String context){
|
||||
boolean flg = false;
|
||||
try{
|
||||
String url = "http://115.29.14.183:3000/openService";
|
||||
HttpPost httppost = new HttpPost(url);
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new BasicNameValuePair("action", action));
|
||||
params.add(new BasicNameValuePair("account", account));
|
||||
params.add(new BasicNameValuePair("password", password));
|
||||
params.add(new BasicNameValuePair("num", phone));
|
||||
params.add(new BasicNameValuePair("sign",sign));
|
||||
params.add(new BasicNameValuePair("content", context+" 退订请回T"));
|
||||
params.add(new BasicNameValuePair("md5", md5));
|
||||
httppost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
|
||||
HttpResponse response = new DefaultHttpClient().execute(httppost);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
String result = EntityUtils.toString(response.getEntity());
|
||||
JSONObject json = new JSONObject(result);
|
||||
flg = json.getBoolean("success");
|
||||
}
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return flg;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(sendcode("13764935808", "尊敬的车商您好! 退订请回T"));
|
||||
}
|
||||
|
||||
}
|
||||
39
src/main/java/com/util/SetJsonObject.java
Normal file
39
src/main/java/com/util/SetJsonObject.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.dubh.common.dto.BaseDto;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JSON构造工具类
|
||||
* @author dubaohui
|
||||
* */
|
||||
public class SetJsonObject implements Serializable{
|
||||
|
||||
|
||||
|
||||
private int total = 0;
|
||||
private List rows;
|
||||
private Object obj;
|
||||
public Object getObj() {
|
||||
return obj;
|
||||
}
|
||||
public void setObj(Object obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
public List getRows() {
|
||||
return rows;
|
||||
}
|
||||
public void setRows(List rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
20
src/main/java/com/util/SpringUtil.java
Normal file
20
src/main/java/com/util/SpringUtil.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.util;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
/**
|
||||
* 工具类
|
||||
* 服务启动时得到SpringBean
|
||||
* @author dubaohui
|
||||
* */
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
private static ApplicationContext applicationContext;
|
||||
public void setApplicationContext(ApplicationContext arg0)
|
||||
throws BeansException {
|
||||
SpringUtil.applicationContext = arg0;
|
||||
}
|
||||
public static Object getBean(String name){
|
||||
return applicationContext.getBean(name);
|
||||
}
|
||||
}
|
||||
|
||||
69
src/main/java/com/util/Student.java
Normal file
69
src/main/java/com/util/Student.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 作者姓名: dubaohui
|
||||
* @version 创建时间:2015-8-12 下午2:40:28
|
||||
* 类说明
|
||||
*/
|
||||
public class Student
|
||||
{
|
||||
private int id;
|
||||
private String name;
|
||||
private int age;
|
||||
private Date birth;
|
||||
|
||||
public Student()
|
||||
{
|
||||
}
|
||||
|
||||
public Student(int id, String name, int age, Date birth)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.birth = birth;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge()
|
||||
{
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age)
|
||||
{
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Date getBirth()
|
||||
{
|
||||
return birth;
|
||||
}
|
||||
|
||||
public void setBirth(Date birth)
|
||||
{
|
||||
this.birth = birth;
|
||||
}
|
||||
|
||||
}
|
||||
166
src/main/java/com/util/SystemTool.java
Normal file
166
src/main/java/com/util/SystemTool.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
|
||||
/**
|
||||
* 与系统相关的一些常用工具方法.
|
||||
*
|
||||
* @author dubaohui
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class SystemTool {
|
||||
|
||||
/**
|
||||
* 获取当前操作系统名称. return 操作系统名称 例如:windows xp,linux 等.
|
||||
*/
|
||||
public static String getOSName() {
|
||||
return System.getProperty("os.name").toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取unix网卡的mac地址. 非windows的系统默认调用本方法获取.
|
||||
* 如果有特殊系统请继续扩充新的取mac地址方法.
|
||||
*
|
||||
* @return mac地址
|
||||
*/
|
||||
public static String getUnixMACAddress() {
|
||||
String mac = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
Process process = null;
|
||||
try {
|
||||
// linux下的命令,一般取eth0作为本地主网卡
|
||||
process = Runtime.getRuntime().exec("ifconfig eth0");
|
||||
// 显示信息中包含有mac地址信息
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream()));
|
||||
String line = null;
|
||||
int index = -1;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
// 寻找标示字符串[hwaddr]
|
||||
index = line.toLowerCase().indexOf("hwaddr");
|
||||
if (index >= 0) {// 找到了
|
||||
// 取出mac地址并去除2边空格
|
||||
mac = line.substring(index + "hwaddr".length() + 1).trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
bufferedReader = null;
|
||||
process = null;
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取widnows网卡的mac地址.
|
||||
*
|
||||
* @return mac地址
|
||||
*/
|
||||
public static String getWindowsMACAddress() {
|
||||
String mac = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
Process process = null;
|
||||
try {
|
||||
// windows下的命令,显示信息中包含有mac地址信息
|
||||
process = Runtime.getRuntime().exec("ipconfig /all");
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream()));
|
||||
String line = null;
|
||||
int index = -1;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
// 寻找标示字符串[physical
|
||||
index = line.toLowerCase().indexOf("physical address");
|
||||
|
||||
if (index >= 0) {// 找到了
|
||||
index = line.indexOf(":");// 寻找":"的位置
|
||||
if (index >= 0) {
|
||||
System.out.println(mac);
|
||||
// 取出mac地址并去除2边空格
|
||||
mac = line.substring(index + 1).trim();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
bufferedReader = null;
|
||||
process = null;
|
||||
}
|
||||
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* windows 7 专用 获取MAC地址
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getMACAddress() throws Exception {
|
||||
|
||||
// 获取本地IP对象
|
||||
InetAddress ia = InetAddress.getLocalHost();
|
||||
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
|
||||
byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
|
||||
|
||||
// 下面代码是把mac地址拼装成String
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < mac.length; i++) {
|
||||
if (i != 0) {
|
||||
sb.append("-");
|
||||
}
|
||||
// mac[i] & 0xFF 是为了把byte转化为正整数
|
||||
String s = Integer.toHexString(mac[i] & 0xFF);
|
||||
sb.append(s.length() == 1 ? 0 + s : s);
|
||||
}
|
||||
|
||||
// 把字符串所有小写字母改为大写成为正规的mac地址并返回
|
||||
return sb.toString().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试用的main方法.
|
||||
*
|
||||
* @param argc 运行参数.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] argc) throws Exception {
|
||||
String os = getOSName();
|
||||
System.out.println(os);
|
||||
if (os.equals("windows 7")) {
|
||||
String mac = getMACAddress();
|
||||
System.out.println(mac);
|
||||
} else if (os.startsWith("windows")) {
|
||||
// 本地是windows
|
||||
String mac = getWindowsMACAddress();
|
||||
System.out.println(mac);
|
||||
} else {
|
||||
// 本地是非windows系统 一般就是unix
|
||||
String mac = getUnixMACAddress();
|
||||
System.out.println(mac);
|
||||
}
|
||||
}
|
||||
}
|
||||
240
src/main/java/com/util/UniqId.java
Normal file
240
src/main/java/com/util/UniqId.java
Normal file
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* @Copyright com.taiyiche
|
||||
* @author 刘峻辉
|
||||
* @description 用户登录token生成器
|
||||
* @date 2016-08-08
|
||||
*/
|
||||
package com.util;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
||||
public class UniqId {
|
||||
private static char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
|
||||
private static Map<Character, Integer> rDigits = new HashMap<Character, Integer>(
|
||||
16);
|
||||
static {
|
||||
for (int i = 0; i < digits.length; ++i) {
|
||||
rDigits.put(digits[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
private static UniqId me = new UniqId();
|
||||
private String hostAddr;
|
||||
private Random random = new SecureRandom();
|
||||
private MessageDigest mHasher;
|
||||
private UniqTimer timer = new UniqTimer();
|
||||
|
||||
private ReentrantLock opLock = new ReentrantLock();
|
||||
|
||||
private UniqId() {
|
||||
try {
|
||||
InetAddress addr = InetAddress.getLocalHost();
|
||||
|
||||
hostAddr = addr.getHostAddress();
|
||||
} catch (IOException e) {
|
||||
hostAddr = String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (hostAddr == null || hostAddr.length() == 0
|
||||
|| "127.0.0.1".equals(hostAddr)) {
|
||||
hostAddr = String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
try {
|
||||
mHasher = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException nex) {
|
||||
mHasher = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取UniqID实例
|
||||
*
|
||||
* @return UniqId
|
||||
*/
|
||||
public static UniqId getInstance() {
|
||||
return me;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得不会重复的毫秒数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getUniqTime() {
|
||||
return timer.getCurrentTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得UniqId
|
||||
*
|
||||
* @return uniqTime-randomNum-hostAddr-threadId
|
||||
*/
|
||||
public String getUniqID() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
long t = timer.getCurrentTime();
|
||||
|
||||
sb.append(t);
|
||||
|
||||
sb.append("-");
|
||||
|
||||
sb.append(random.nextInt(8999) + 1000);
|
||||
|
||||
sb.append("-");
|
||||
sb.append(hostAddr);
|
||||
|
||||
sb.append("-");
|
||||
sb.append(Thread.currentThread().hashCode());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MD5之后的uniqId string
|
||||
*
|
||||
* @return uniqId md5 string
|
||||
*/
|
||||
public String getUniqIDHashString() {
|
||||
return hashString(getUniqID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MD5之后的uniqId
|
||||
*
|
||||
* @return byte[16]
|
||||
*/
|
||||
public byte[] getUniqIDHash() {
|
||||
return hash(getUniqID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 对字符串进行md5
|
||||
*
|
||||
* @param str
|
||||
* @return md5 byte[16]
|
||||
*/
|
||||
public byte[] hash(String str) {
|
||||
opLock.lock();
|
||||
try {
|
||||
byte[] bt = mHasher.digest(str.getBytes("UTF-8"));
|
||||
if (null == bt || bt.length != 16) {
|
||||
throw new IllegalArgumentException("md5 need");
|
||||
}
|
||||
return bt;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("unsupported utf-8 encoding", e);
|
||||
} finally {
|
||||
opLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对二进制数据进行md5
|
||||
*
|
||||
* @param str
|
||||
* @return md5 byte[16]
|
||||
*/
|
||||
public byte[] hash(byte[] data) {
|
||||
opLock.lock();
|
||||
try {
|
||||
byte[] bt = mHasher.digest(data);
|
||||
if (null == bt || bt.length != 16) {
|
||||
throw new IllegalArgumentException("md5 need");
|
||||
}
|
||||
return bt;
|
||||
} finally {
|
||||
opLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对字符串进行md5 string
|
||||
*
|
||||
* @param str
|
||||
* @return md5 string
|
||||
*/
|
||||
public String hashString(String str) {
|
||||
byte[] bt = hash(str);
|
||||
return bytes2string(bt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对字节流进行md5 string
|
||||
*
|
||||
* @param str
|
||||
* @return md5 string
|
||||
*/
|
||||
public String hashBytes(byte[] str) {
|
||||
byte[] bt = hash(str);
|
||||
return bytes2string(bt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字节数组转化为可见的字符串
|
||||
*
|
||||
* @param bt
|
||||
* @return
|
||||
*/
|
||||
public String bytes2string(byte[] bt) {
|
||||
int l = bt.length;
|
||||
|
||||
char[] out = new char[l << 1];
|
||||
|
||||
for (int i = 0, j = 0; i < l; i++) {
|
||||
out[j++] = digits[(0xF0 & bt[i]) >>> 4];
|
||||
out[j++] = digits[0x0F & bt[i]];
|
||||
}
|
||||
|
||||
return new String(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换为bytes
|
||||
*
|
||||
* @param str
|
||||
* @return byte[]
|
||||
*/
|
||||
public byte[] string2bytes(String str) {
|
||||
if (null == str) {
|
||||
throw new NullPointerException("参数不能为空");
|
||||
}
|
||||
if (str.length() != 32) {
|
||||
throw new IllegalArgumentException("字符串长度必须是32");
|
||||
}
|
||||
byte[] data = new byte[16];
|
||||
char[] chs = str.toCharArray();
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
int h = rDigits.get(chs[i * 2]).intValue();
|
||||
int l = rDigits.get(chs[i * 2 + 1]).intValue();
|
||||
data[i] = (byte) ((h & 0x0F) << 4 | (l & 0x0F));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现不重复的时间
|
||||
*
|
||||
* @author dogun
|
||||
*/
|
||||
private static class UniqTimer {
|
||||
private AtomicLong lastTime = new AtomicLong(System.currentTimeMillis());
|
||||
|
||||
public long getCurrentTime() {
|
||||
return this.lastTime.incrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
917
src/main/java/com/util/UtilTools.java
Normal file
917
src/main/java/com/util/UtilTools.java
Normal file
@@ -0,0 +1,917 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhongdao.jlr.enums.Week;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class UtilTools {
|
||||
private static final String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
||||
private static final String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
||||
private static final String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
private static final String bxcompanykey = "2016052210383737344";// 太保上海分公司编号
|
||||
private static final String sysrolekey = "20150807152252189885";// 管理员角色编号
|
||||
private static final String adminCode = "2015050608332656789";// 超级管理员(admin)主键编号
|
||||
|
||||
public static String getCode(String codeStr) {
|
||||
String str = "";
|
||||
if (codeStr.equals("bxcompanykey")) {
|
||||
str = bxcompanykey;
|
||||
} else if (codeStr.equals("sysrolekey")) {
|
||||
str = sysrolekey;
|
||||
} else if (codeStr.equals("adminCode")) {
|
||||
str = adminCode;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取List长度
|
||||
*
|
||||
* @param List
|
||||
* @return int
|
||||
*
|
||||
*/
|
||||
public static Integer ListCount(List list) {
|
||||
Integer count = new Integer(0);
|
||||
if (list != null && list.size() > 0) {
|
||||
count = list.size();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到当前日期 gs(格式):自定义
|
||||
*/
|
||||
public static String getTime(String gs) {
|
||||
SimpleDateFormat df = new SimpleDateFormat(gs);
|
||||
String currentdate = df.format(new Date());
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体时间精确到日
|
||||
*/
|
||||
public static String getTimeForD() {
|
||||
return getTime("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体时间精确到日
|
||||
*/
|
||||
public static String getTimeForD(String format) {
|
||||
return getTime(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体时间精确到时
|
||||
*/
|
||||
public static String getTimeForH() {
|
||||
return getTime("yyyy-MM-dd HH");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体时间精确到分
|
||||
*/
|
||||
public static String getTimeForM() {
|
||||
return getTime("yyyy-MM-dd HH:mm");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体时间精确到秒
|
||||
*/
|
||||
public static String getTimeForS() {
|
||||
return getTime("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除HTML标签
|
||||
*
|
||||
* @param htmlStr
|
||||
* @return
|
||||
*/
|
||||
public static String delHTMLTag(String htmlStr) {
|
||||
Pattern p_script = Pattern.compile(regEx_script,
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
Pattern p_style = Pattern
|
||||
.compile(regEx_style, Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_style = p_style.matcher(htmlStr);
|
||||
htmlStr = m_style.replaceAll(""); // 过滤style标签
|
||||
|
||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
htmlStr = htmlStr.replaceAll(" ", " ");// 过滤空格标签
|
||||
|
||||
return htmlStr.trim(); // 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* Date转String gs:时间格式
|
||||
*/
|
||||
public static String dateToString(Date date, String gs) {
|
||||
String result = "";
|
||||
SimpleDateFormat df = new SimpleDateFormat(gs);
|
||||
result = df.format(date);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* String转Date sj:时间,默认"yyyy-MM-dd" gs:时间格式
|
||||
*/
|
||||
public static Date stringToDate(String sj, String gs) {
|
||||
Date date = null;
|
||||
if (!strNotNull(sj)) {
|
||||
sj = getTimeForD();
|
||||
}
|
||||
SimpleDateFormat df = new SimpleDateFormat(gs);
|
||||
try {
|
||||
date = df.parse(sj);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为null或空
|
||||
*/
|
||||
public static boolean strNotNull(String str) {
|
||||
if (null != str && !"".equals(str.trim())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean strNotNullAndNullStr(String str) {
|
||||
if (null != str && !"".equals(str.trim()) && !"null".equals(str.trim())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义添加Day获取新的日期 yyyy-MM-dd
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static String getNewDateForDay(Integer day) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String rq = getTimeForD();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
try {
|
||||
calendar.setTime(sdf.parse(rq));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
calendar.add(Calendar.DAY_OF_MONTH, day);
|
||||
rq = sdf.format(calendar.getTime());
|
||||
return rq;
|
||||
}
|
||||
|
||||
/**
|
||||
* list转换为jsonArray
|
||||
*
|
||||
* @param list
|
||||
* @param names
|
||||
* @return
|
||||
*/
|
||||
public static JSONArray listTojsonArray(List list, String[] names) {
|
||||
JSONArray jarry = new JSONArray();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] obj = (Object[]) list.get(i);
|
||||
JSONObject object = new JSONObject();
|
||||
for (int j = 0; j < names.length; j++) {
|
||||
object.put(names[j],
|
||||
null == obj[j] ? "" : obj[j].toString());
|
||||
}
|
||||
jarry.add(object);
|
||||
}
|
||||
}
|
||||
return jarry;
|
||||
}
|
||||
|
||||
/**
|
||||
* list转换为jsonObject
|
||||
*
|
||||
* @param list
|
||||
* @param names
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject listTojsonObject(List list, String[] names) {
|
||||
JSONObject object= new JSONObject();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] obj = (Object[]) list.get(i);
|
||||
object = new JSONObject();
|
||||
for (int j = 0; j < names.length; j++) {
|
||||
object.put(names[j],
|
||||
null == obj[j] ? "" : obj[j].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
/**
|
||||
* 返回新的字符串格式 'p1','p2',.....
|
||||
*
|
||||
* @param str
|
||||
* 要转换的字符串
|
||||
* @param separator
|
||||
* 字符串之间的分隔符 ,值为null时,默认为','
|
||||
* @return
|
||||
*/
|
||||
public static String strToNewStr(String str, String separator) {
|
||||
String result = "";
|
||||
if (null != str && !"".equals(str)) {
|
||||
if (null == separator)
|
||||
separator = ",";
|
||||
String[] nstr = str.split(separator);
|
||||
for (int i = 0; i < nstr.length; i++) {
|
||||
if (!"".equals(result)) {
|
||||
result += ",";
|
||||
}
|
||||
result += "'" + nstr[i] + "'";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否是数字 true:数字 false:非数字
|
||||
*/
|
||||
public static boolean isNumber(String str) {
|
||||
if (null != str
|
||||
&& !"".equals(str.trim())
|
||||
&& str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把Vo 封装成jsonObj
|
||||
*
|
||||
* @param v
|
||||
* @param thistablesx
|
||||
* @return
|
||||
*/
|
||||
public static SetJsonObject voToJsonObj(Vo v, String[] thistablesx) {
|
||||
long startTime=System.currentTimeMillis();
|
||||
JSONArray json = new JSONArray();
|
||||
SetJsonObject jsonObj = new SetJsonObject();
|
||||
try {
|
||||
for (int i = 0; i < v.getRows().size(); i++) {
|
||||
Object[] obj = (Object[]) v.getRows().get(i);
|
||||
JSONObject jobj = new JSONObject();
|
||||
for (int j = 0; j < thistablesx.length; j++) {
|
||||
String strarr = null == obj[j] ? "" : obj[j].toString();
|
||||
String str = thistablesx[j];
|
||||
jobj.put(str, strarr);
|
||||
}
|
||||
json.add(jobj);
|
||||
}
|
||||
jsonObj.setRows(json);
|
||||
jsonObj.setTotal(v.getTotal());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("voToJsonObjTime:"+(System.currentTimeMillis()-startTime));
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
public static SetJsonObject voToJsonObj(Vo v) {
|
||||
SetJsonObject jsonObj = new SetJsonObject();
|
||||
jsonObj.setRows(v.getRows());
|
||||
jsonObj.setTotal(v.getTotal());
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把List 封装成jsonObj
|
||||
*
|
||||
* @param v
|
||||
* @param thistablesx
|
||||
* @return
|
||||
*/
|
||||
public static SetJsonObject listToJsonObj(List list, String[] thistablesx) {
|
||||
JSONArray json = new JSONArray();
|
||||
SetJsonObject jsonObj = new SetJsonObject();
|
||||
try {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] obj = (Object[]) list.get(i);
|
||||
JSONObject jobj = new JSONObject();
|
||||
for (int j = 0; j < thistablesx.length; j++) {
|
||||
String strarr = null == obj[j] ? "" : obj[j].toString();
|
||||
String str = thistablesx[j];
|
||||
jobj.put(str, strarr);
|
||||
}
|
||||
json.add(jobj);
|
||||
}
|
||||
jsonObj.setRows(json);
|
||||
jsonObj.setTotal(list.size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
/**
|
||||
* 把List 封装成jsonObj
|
||||
*
|
||||
* @param v
|
||||
* @param thistablesx
|
||||
* @return
|
||||
*/
|
||||
public static JSONArray listToJsonObj2(List list, String[] thistablesx) {
|
||||
JSONArray json = new JSONArray();
|
||||
try {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] obj = (Object[]) list.get(i);
|
||||
JSONObject jobj = new JSONObject();
|
||||
for (int j = 0; j < thistablesx.length; j++) {
|
||||
String strarr = null == obj[j] ? "" : obj[j].toString();
|
||||
String str = thistablesx[j];
|
||||
jobj.put(str, strarr);
|
||||
}
|
||||
json.add(jobj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
/**
|
||||
* 得到前天 昨天 今天 明天的日期 -1代表前一天 1代表后一天 等等 默认 yyyy-MM-dd
|
||||
*/
|
||||
public static String getTcTime(String style, int numb) {
|
||||
if (!UtilTools.strNotNull(style)) {
|
||||
style = "yyyy-MM-dd";
|
||||
}
|
||||
Date date = new Date();// 取时间
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
calendar.add(calendar.DATE, numb);// 把日期往后增加一天.整数往后推,负数往前移动
|
||||
date = calendar.getTime(); // 这个时间就是日期往后推一天的结果
|
||||
SimpleDateFormat formatter = new SimpleDateFormat(style);
|
||||
String dateString = formatter.format(date);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到上一个月第一天
|
||||
*/
|
||||
public static String getMMTop() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MONTH, -1);
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
||||
String time = format.format(c.getTime());
|
||||
return time + "-01";
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到上一个月最后一天
|
||||
*/
|
||||
public static String getMMNext() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MONTH, -1);
|
||||
int MaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
// 按你的要求设置时间
|
||||
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), MaxDay, 23, 59, 59);
|
||||
// 按格式输出
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String gtime = sdf.format(c.getTime()); // 上月最后一天
|
||||
return gtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到page
|
||||
*
|
||||
* @return mysql默认0 oracle默认1
|
||||
*/
|
||||
public static Integer getPage(HttpServletRequest request) {
|
||||
Integer page = 1;
|
||||
if (null != request && null != request.getParameter("page")
|
||||
&& isNumber(request.getParameter("page"))) {
|
||||
return Integer.parseInt(request.getParameter("page"));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到rows
|
||||
*
|
||||
* @return 默认10
|
||||
*/
|
||||
public static Integer getRows(HttpServletRequest request) {
|
||||
Integer rows = 10;
|
||||
if (null != request && null != request.getParameter("rows")
|
||||
&& isNumber(request.getParameter("rows"))) {
|
||||
return Integer.parseInt(request.getParameter("rows"));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串首字母转换大写
|
||||
*/
|
||||
public static String szmZdx(String result) {
|
||||
String result1 = "";
|
||||
if (null != result && !"".equals(result)) {
|
||||
result1 = result.substring(0, 1).toUpperCase()
|
||||
+ result.substring(1, result.length());
|
||||
}
|
||||
return result1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器地址:如:http://192.168.1.100:8080/web
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getWebAddress(HttpServletRequest request) {
|
||||
String web1 = request.getServerName();
|
||||
// 把localhost替换成本机ip
|
||||
if (web1.equals("localhost")) {
|
||||
try {
|
||||
web1 = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String path = "http://" + web1 + ":" + request.getServerPort()
|
||||
+ request.getContextPath();
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断手机号码是否正确
|
||||
*
|
||||
* @param mobiles
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMobileNO(String mobiles) {
|
||||
Pattern p = Pattern
|
||||
.compile("^(13[0-9]|15[012356789]|17[36780]|18[0-9]|14[57])[0-9]{8}$");
|
||||
Matcher m = p.matcher(mobiles);
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
*/
|
||||
public static String getOrderState(Integer state) {
|
||||
String str = "初始值";
|
||||
if (0 == state) {
|
||||
str = "初始值";
|
||||
} else if (5 == state) {
|
||||
str = "待取车预约";
|
||||
} else if (10 == state) {
|
||||
str = "取车预约失败";
|
||||
} else if (15 == state) {
|
||||
str = "待取车派单";
|
||||
} else if (20 == state) {
|
||||
str = "待取车邀约";
|
||||
} else if (30 == state) {
|
||||
str = "取车邀约失败";
|
||||
} else if (31 == state) {
|
||||
str = "待取车";
|
||||
} else if (32 == state) {
|
||||
str = "取车条件不符";
|
||||
} else if (33 == state) {
|
||||
str = "待送修";
|
||||
} else if (34 == state) {
|
||||
str = "取车失败";
|
||||
} else if (343 == state) {
|
||||
str = "等待定损";
|
||||
}else if (345 == state) {
|
||||
str = "还车预约";
|
||||
}else if (347 == state) {
|
||||
str = "还车派单";
|
||||
}else if (35 == state) {
|
||||
str = "待还车邀约";
|
||||
} else if (351 == state) {
|
||||
str = "邀约失败重新";
|
||||
}else if (352 == state) {
|
||||
str = "邀约失败重新派单";
|
||||
}else if (36 == state) {
|
||||
str = "待维修网点取车";
|
||||
}else if (361 == state) {
|
||||
str = "提车失败";
|
||||
} else if (37 == state) {
|
||||
str = "待还车";
|
||||
}else if (371 == state) {
|
||||
str = "还车失败";
|
||||
} else if (40 == state) {
|
||||
str = "待理赔";
|
||||
} else if (100 == state) {
|
||||
str = "理赔完毕";
|
||||
} else if (101 == state) {
|
||||
str = "强制废除";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
*/
|
||||
public static String getOrderState(String state) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
if ("初始值".contains(state)) {
|
||||
str.append("0,");
|
||||
} else if ("待取车预约".equals(state)) {
|
||||
str.append("5,");
|
||||
} else if ("取车预约失败".equals(state)) {
|
||||
str.append("10,");
|
||||
} else if ("待取车派单".equals(state)) {
|
||||
str.append("15,");
|
||||
} else if ("待取车邀约".equals(state)) {
|
||||
str.append("20,");
|
||||
} else if ("取车邀约成功".equals(state)) {
|
||||
str.append("25,");
|
||||
} else if ("取车邀约失败".equals(state)) {
|
||||
str.append("30,");
|
||||
} else if ("待取车".equals(state)) {
|
||||
str.append("31,");
|
||||
} else if ("待送修".equals(state)) {
|
||||
str.append("33,");
|
||||
} else if ("取车失败".equals(state)) {
|
||||
str.append("34,");
|
||||
} else if ("等待定损".equals(state)) {
|
||||
str.append("343,");
|
||||
} else if ("还车预约".equals(state)) {
|
||||
str.append("345,");
|
||||
} else if ("还车派单".equals(state)) {
|
||||
str.append("347,");
|
||||
}
|
||||
else if ("待还车邀约".equals(state)) {
|
||||
str.append("35,");
|
||||
}
|
||||
else if ("邀约失败重新预约".equals(state)) {
|
||||
str.append("351,");
|
||||
} else if ("邀约失败重新派单".equals(state)) {
|
||||
str.append("352,");
|
||||
}
|
||||
else if ("待维修网点取车".equals(state)) {
|
||||
str.append("36,");
|
||||
} else if ("提车失败".equals(state)) {
|
||||
str.append("361,");
|
||||
} else if ("待还车".equals(state)) {
|
||||
str.append("37,");
|
||||
} else if ("还车失败 ".equals(state)) {
|
||||
str.append("371,");
|
||||
} else if ("还车成功待理赔".equals(state)) {
|
||||
str.append("40,");
|
||||
} else if ("理赔完毕".equals(state)) {
|
||||
str.append("100,");
|
||||
} else if ("强制废除".equals(state)) {
|
||||
str.append("101,");
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
/**
|
||||
* 获取状态App
|
||||
*/
|
||||
public static String getOrderStateApp(String state) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
if ("初始值".contains(state)) {
|
||||
str.append("0,");
|
||||
} else if ("取车预约".equals(state)) {
|
||||
str.append("5,");
|
||||
} else if ("预约失败".equals(state)) {
|
||||
str.append("10,");
|
||||
} else if ("取车派单".equals(state)) {
|
||||
str.append("15,");
|
||||
} else if ("取车邀约".equals(state)) {
|
||||
str.append("20,");
|
||||
} else if ("邀约失败".equals(state)) {
|
||||
str.append("30,");
|
||||
} else if ("取车".equals(state)) {
|
||||
str.append("31,");
|
||||
} else if ("送修".equals(state)) {
|
||||
str.append("33,");
|
||||
} else if ("取车失败".equals(state)) {
|
||||
str.append("34,");
|
||||
} else if ("定损".equals(state)) {
|
||||
str.append("343,");
|
||||
} else if ("还车预约".equals(state)) {
|
||||
str.append("345,");
|
||||
} else if ("还车派单".equals(state)) {
|
||||
str.append("347,");
|
||||
}
|
||||
else if ("还车邀约".equals(state)) {
|
||||
str.append("35,");
|
||||
}
|
||||
else if ("重新预约".equals(state)) {
|
||||
str.append("351,");
|
||||
} else if ("重新派单".equals(state)) {
|
||||
str.append("352,");
|
||||
}
|
||||
else if ("提车".equals(state)) {
|
||||
str.append("36,");
|
||||
} else if ("提车失败".equals(state)) {
|
||||
str.append("361,");
|
||||
} else if ("还车".equals(state)) {
|
||||
str.append("37,");
|
||||
} else if ("还车失败 ".equals(state)) {
|
||||
str.append("371,");
|
||||
} else if ("理赔".equals(state)) {
|
||||
str.append("40,");
|
||||
} else if ("理赔完毕".equals(state)) {
|
||||
str.append("100,");
|
||||
} else if ("强制废除".equals(state)) {
|
||||
str.append("101,");
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态4SApp
|
||||
*/
|
||||
public static String get4SOrderStateApp(String state) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
if ("等待送修".contains(state)) {
|
||||
str.append("5,");
|
||||
} else if ("送修途中".equals(state)) {
|
||||
str.append("10,");
|
||||
} else if ("返修途中".equals(state)) {
|
||||
str.append("20,");
|
||||
} else if ("接车成功".equals(state)) {
|
||||
str.append("30,");
|
||||
} else if ("交车失败".equals(state)) {
|
||||
str.append("35,");
|
||||
} else if ("开始维修".equals(state)) {
|
||||
str.append("40,");
|
||||
} else if ("维修完毕".equals(state)) {
|
||||
str.append("50,");
|
||||
} else if ("等待交车".equals(state)) {
|
||||
str.append("60,");
|
||||
} else if ("交车成功".equals(state)) {
|
||||
str.append("70,");
|
||||
} else if ("接车失败".equals(state)) {
|
||||
str.append("15,");
|
||||
} else if ("结账完毕".equals(state)) {
|
||||
str.append("100,");
|
||||
} else if ("强制撤销".equals(state)) {
|
||||
str.append("101,");
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组号
|
||||
*/
|
||||
public static int getModenoByFiletype(int filetype) {
|
||||
if (filetype == 6 || filetype == 7 || filetype == 101) {
|
||||
return 0;
|
||||
} else if (filetype == 8) {
|
||||
return 1;
|
||||
} else if (filetype >= 9 && filetype <= 12) {
|
||||
return 2;
|
||||
} else if (filetype == 13) {
|
||||
return 3;
|
||||
} else if (filetype >= 14 && filetype <= 17) {
|
||||
return 4;
|
||||
} else if (filetype == 18) {
|
||||
return 5;
|
||||
} else if (filetype >= 19 && filetype <= 22) {
|
||||
return 6;
|
||||
} else if (filetype == 23) {
|
||||
return 7;
|
||||
} else if (filetype >= 24 && filetype <= 27) {
|
||||
return 8;
|
||||
} else if (filetype == 28) {
|
||||
return 9;
|
||||
} else if (filetype >= 29 && filetype <= 30) {
|
||||
return 10;
|
||||
} else if (filetype == 31) {
|
||||
return 11;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户类型
|
||||
*/
|
||||
public static String getOrderCustomlb(String state) {
|
||||
if ("A类".equals(state)) {
|
||||
return "A";
|
||||
} else if ("B类".equals(state)) {
|
||||
return "B";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
public static boolean downFile(HttpServletResponse response, String path) {
|
||||
boolean flag = false;
|
||||
File file = null;
|
||||
try {
|
||||
file = new File(path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (null != file) {
|
||||
if (file.exists()) {
|
||||
try {
|
||||
String filename = file.getName();
|
||||
// 弹出下载对话框
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream");
|
||||
filename = new String(filename.getBytes(System
|
||||
.getProperty("file.encoding")), "ISO-8859-1");
|
||||
response.addHeader("Content-Disposition",
|
||||
"attachment;filename=\"" + filename + "\"");
|
||||
OutputStream os = os = response.getOutputStream();
|
||||
InputStream is = is = new FileInputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
// 用输入流进行先读,然后用输出流去写
|
||||
int bytesRead = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
while ((bytesRead = bis.read(buffer, 0, 8192)) != -1) {
|
||||
bos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
os.flush();
|
||||
os.close();
|
||||
is.close();
|
||||
flag = true;
|
||||
} catch (IOException e) {
|
||||
flag = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static String parsJsonString(org.json.JSONObject json, String params) {
|
||||
try {
|
||||
return json.getString(params);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个日期,返回是星期几的字符串
|
||||
*
|
||||
* @param sdate
|
||||
* @return
|
||||
*/
|
||||
// public static String getWeek(String sdate) {
|
||||
// // 再转换为时间
|
||||
// Date date =strToDate(sdate);
|
||||
// Calendar c = Calendar.getInstance();
|
||||
// c.setTime(date);
|
||||
// // int hour=c.get(Calendar.DAY_OF_WEEK);
|
||||
// // hour中存的就是星期几了,其范围 1~7
|
||||
// // 1=星期日 7=星期六,其他类推
|
||||
// return new SimpleDateFormat("EEEE").format(c.getTime());
|
||||
// }
|
||||
public static Week getWeekStr(String sdate) {
|
||||
int year = Integer.parseInt(sdate.substring(0, 4));
|
||||
int month = Integer.parseInt(sdate.substring(5, 7));
|
||||
int day = Integer.parseInt(sdate.substring(8, 10));
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
c.set(Calendar.YEAR, year);
|
||||
c.set(Calendar.MONTH, month - 1);
|
||||
c.set(Calendar.DAY_OF_MONTH, day);
|
||||
|
||||
String str = c.get(Calendar.DAY_OF_WEEK) + "";
|
||||
|
||||
if ("1".equals(str)) {
|
||||
return Week.SUN;
|
||||
} else if ("2".equals(str)) {
|
||||
return Week.MON;
|
||||
} else if ("3".equals(str)) {
|
||||
return Week.TUE;
|
||||
} else if ("4".equals(str)) {
|
||||
return Week.WEN;
|
||||
} else if ("5".equals(str)) {
|
||||
return Week.THU;
|
||||
} else if ("6".equals(str)) {
|
||||
return Week.FRI;
|
||||
} else if ("7".equals(str)) {
|
||||
return Week.SAT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将短时间格式字符串转换为时间 yyyy-MM-dd
|
||||
*
|
||||
* @param strDate
|
||||
* @return
|
||||
*/
|
||||
public static Date strToDate(String strDate) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
Date strtodate = formatter.parse(strDate, pos);
|
||||
return strtodate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串的日期格式的计算
|
||||
*/
|
||||
public static int daysBetween(String smdate, String bdate)
|
||||
throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(sdf.parse(smdate));
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(sdf.parse(bdate));
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
}
|
||||
/**
|
||||
* 获得指定日期的前一天
|
||||
*
|
||||
* @param specifiedDay
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getSpecifiedDayBefore(String specifiedDay) {
|
||||
// SimpleDateFormat simpleDateFormat = new
|
||||
// SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day - 1);
|
||||
|
||||
String dayBefore = new SimpleDateFormat("yyyy-MM-dd").format(c
|
||||
.getTime());
|
||||
return dayBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定日期的后一天
|
||||
*
|
||||
* @param specifiedDay
|
||||
* @return
|
||||
*/
|
||||
public static String getSpecifiedDayAfter(String specifiedDay) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day + 1);
|
||||
|
||||
String dayAfter = new SimpleDateFormat("yyyy-MM-dd")
|
||||
.format(c.getTime());
|
||||
return dayAfter;
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/com/util/Vo.java
Normal file
30
src/main/java/com/util/Vo.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.util;
|
||||
|
||||
import com.dubh.common.dto.BaseDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Vo extends BaseDto{
|
||||
private List rows;
|
||||
private Integer total;
|
||||
public List getRows() {
|
||||
return rows;
|
||||
}
|
||||
public void setRows(List rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Vo{" +
|
||||
"rows=" + rows +
|
||||
", total=" + total +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
518
src/main/java/com/util/ZipUtil.java
Normal file
518
src/main/java/com/util/ZipUtil.java
Normal file
@@ -0,0 +1,518 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.CheckedOutputStream;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 功能:使用Apache Ant里提供的org.apache.tools.zip实现zip压缩和解压 (支持中文文件名)
|
||||
* 解决了由于java.util.zip包不支持汉字的问题。 使用java.util.zip包时,当zip文件中有名字为中文的文件时,
|
||||
* 就会出现异常:"Exception in thread "main " java.lang.IllegalArgumentException at
|
||||
* java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:285)
|
||||
*
|
||||
* @author 夏明龙 E-mail:邮箱
|
||||
* @version 创建时间:2013-3-22 上午10:40:21 类说明:
|
||||
*/
|
||||
public class ZipUtil {
|
||||
private static List list = new ArrayList();
|
||||
|
||||
private static List listFile(String path) {
|
||||
File file = new File(path);
|
||||
String[] array = null;
|
||||
String sTemp = "";
|
||||
|
||||
if (!file.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
array = file.list();
|
||||
if (array.length > 0) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
sTemp = path + array[i];
|
||||
file = new File(sTemp);
|
||||
if (file.isDirectory()) {
|
||||
listFile(sTemp + "/");
|
||||
} else
|
||||
list.add(sTemp);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void zip(String needtozipfilepath) {
|
||||
try {
|
||||
byte[] b = new byte[512];
|
||||
|
||||
File needtozipfile = new File(needtozipfilepath);
|
||||
|
||||
if (!needtozipfile.exists()) {
|
||||
System.err.println("指定的要压缩的文件或目录不存在.");
|
||||
return;
|
||||
}
|
||||
|
||||
String zipFile = needtozipfilepath + ".zip";
|
||||
System.out.println("zipFile:" + zipFile);
|
||||
// File targetFile = new File(zipFile.substring(0,
|
||||
// zipFile.indexOf("\\") + 1));
|
||||
//
|
||||
// if (!targetFile.exists()) {
|
||||
// System.out.println("指定的目标文件或目录不存在.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
String filepath = needtozipfilepath;
|
||||
List fileList = listFile(filepath + "/");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
|
||||
CheckedOutputStream cs = new CheckedOutputStream(fileOutputStream,
|
||||
new CRC32());
|
||||
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
|
||||
cs));
|
||||
|
||||
for (int i = 0; i < fileList.size(); i++) {
|
||||
InputStream in = new FileInputStream((String) fileList.get(i));
|
||||
String fileName = ((String) fileList.get(i)).replace(
|
||||
File.separatorChar, '/');
|
||||
fileName = fileName.substring(fileName.indexOf("/") + 1);
|
||||
ZipEntry e = new ZipEntry(fileName);
|
||||
out.putNextEntry(e);
|
||||
int len = 0;
|
||||
while ((len = in.read(b)) != -1) {
|
||||
out.write(b, 0, len);
|
||||
}
|
||||
out.closeEntry();
|
||||
}
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////
|
||||
/**
|
||||
* 压缩文件 或者 文件夹
|
||||
*
|
||||
* @param baseDirName
|
||||
* 压缩的根目录
|
||||
* @param fileName
|
||||
* 根目录下待压缩的文件或文件夹名
|
||||
* @param targetFileName
|
||||
* 目标ZIP 文件 星号 "*" 表示压缩根目录下的全部文件
|
||||
*
|
||||
*/
|
||||
public static boolean zip(String baseDirName, String[] fileNames,
|
||||
String targetFileName, String encoding) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
// 判断 "压缩的根目录"是否存在! 是否是一个文件夹!
|
||||
File baseDir = new File(baseDirName);
|
||||
if (!baseDir.exists() || (!baseDir.isDirectory())) {
|
||||
System.err.println("压缩失败! 根目录不存在: " + baseDirName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 得到这个 "压缩的根目录" 的绝对路径
|
||||
String baseDirPath = baseDir.getAbsolutePath();
|
||||
|
||||
// 由这个 "目标 ZIP 文件" 文件名得到一个 压缩对象 ZipOutputStream
|
||||
File targetFile = new File(targetFileName);
|
||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
|
||||
targetFile));
|
||||
// 中文有乱码,引进下面的改造类
|
||||
// CnZipOutputStream out = new CnZipOutputStream(new
|
||||
// FileOutputStream(targetFile),encoding);
|
||||
|
||||
// 设置压缩编码Apache Ant有个包专门处理ZIP文件,可以指定文件名的编码方式。由此可以解决问题。例如:用
|
||||
// org.apache.tools.zip.ZipOutputStream代替java.util.zip.ZipOutputStream。ZipOutputStream
|
||||
// out = .....; out.setEncoding("GBK");
|
||||
// out.setEncoding("GBK");//设置为GBK后在windows下就不会乱码了,如果要放到Linux或者Unix下就不要设置了
|
||||
out.setEncoding(encoding);
|
||||
|
||||
// "*" 表示压缩包括根目录 baseDirName 在内的全部文件 到 targetFileName文件下
|
||||
if (fileNames.equals("*")) {
|
||||
ZipUtil.dirToZip(baseDirPath, baseDir, out);
|
||||
} else {
|
||||
File[] files = new File[fileNames.length];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
// 根据 parent 抽象路径名和 child 路径名字符串创建一个新 File 实例。
|
||||
files[i] = new File(baseDir, fileNames[i]);
|
||||
}
|
||||
if (files[0].isFile()) {
|
||||
// 调用本类的一个静态方法 压缩一个文件
|
||||
// CompressUtil.fileToZip(baseDirPath, file, out);
|
||||
ZipUtil.filesToZip(baseDirPath, files, out);
|
||||
}
|
||||
|
||||
}
|
||||
out.close();
|
||||
// System.out.println("压缩成功! 目标文件名为: " + targetFileName);
|
||||
flag = true;
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件压缩到Zip 输出流
|
||||
*
|
||||
* @param baseDirPath
|
||||
* 根目录路径
|
||||
* @param file
|
||||
* 要压缩的文件
|
||||
* @param out
|
||||
* 输出流
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void fileToZip(String baseDirPath, File file,
|
||||
ZipOutputStream out) throws IOException {
|
||||
//
|
||||
FileInputStream in = null;
|
||||
org.apache.tools.zip.ZipEntry entry = null;
|
||||
// 创建复制缓冲区 1024*4 = 4K
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
int bytes_read = 0;
|
||||
if (file.isFile()) {
|
||||
in = new FileInputStream(file);
|
||||
// 根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例
|
||||
String zipFileName = getEntryName(baseDirPath, file);
|
||||
entry = new org.apache.tools.zip.ZipEntry(zipFileName);
|
||||
// "压缩文件" 对象加入 "要压缩的文件" 对象
|
||||
out.putNextEntry(entry);
|
||||
// 现在是把 "要压缩的文件" 对象中的内容写入到 "压缩文件" 对象
|
||||
while ((bytes_read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, bytes_read);
|
||||
}
|
||||
out.closeEntry();
|
||||
in.close();
|
||||
// System.out.println("添加文件" + file.getAbsolutePath()+ "被添加到 ZIP
|
||||
// 文件中!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个文件目录压缩到Zip 输出流
|
||||
*
|
||||
* @param baseDirPath
|
||||
* @param files
|
||||
* @param out
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void filesToZip(String baseDirPath, File[] files,
|
||||
ZipOutputStream out) throws IOException {
|
||||
// 遍历所有的文件 一个一个地压缩
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (file.isFile()) {
|
||||
// 调用本类的一个静态方法 压缩一个文件
|
||||
ZipUtil.fileToZip(baseDirPath, file, out);
|
||||
} else {
|
||||
/*
|
||||
* 这是一个文件夹 所以要再次得到它下面的所有的文件 这里是自己调用自己..............递归..........
|
||||
*/
|
||||
ZipUtil.dirToZip(baseDirPath, file, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件目录压缩到Zip 输出流
|
||||
*
|
||||
* @param baseDirPath
|
||||
* @param dir
|
||||
* @param out
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void dirToZip(String baseDirPath, File dir,
|
||||
ZipOutputStream out) throws IOException {
|
||||
// 得到一个文件列表 (本目录下的所有文件对象集合)
|
||||
File[] files = dir.listFiles();
|
||||
// 要是这个文件集合数组的长度为 0 , 也就证明了这是一个空的文件夹,虽然没有再循环遍历它的必要,但是也要把这个空文件夹也压缩到目标文件中去
|
||||
if (files.length == 0) {
|
||||
// 根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例
|
||||
String zipFileName = getEntryName(baseDirPath, dir);
|
||||
org.apache.tools.zip.ZipEntry entry = new org.apache.tools.zip.ZipEntry(
|
||||
zipFileName);
|
||||
out.putNextEntry(entry);
|
||||
out.closeEntry();
|
||||
} else {
|
||||
// 遍历所有的文件 一个一个地压缩
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (file.isFile()) {
|
||||
// 调用本类的一个静态方法 压缩一个文件
|
||||
ZipUtil.fileToZip(baseDirPath, file, out);
|
||||
} else {
|
||||
/*
|
||||
* 这是一个文件夹 所以要再次得到它下面的所有的文件
|
||||
* 这里是自己调用自己..............递归..........
|
||||
*/
|
||||
ZipUtil.dirToZip(baseDirPath, file, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 待压缩文件在 ZIP 文件中的 entry的名字,即相对于根目录的相对路径名
|
||||
*
|
||||
* @param baseDirPath
|
||||
* 根目录
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
private static String getEntryName(String baseDirPath, File file) {
|
||||
/**
|
||||
* 改变 baseDirPath 的形式 把 "C:/temp" 变成 "C:/temp/"
|
||||
*/
|
||||
if (!baseDirPath.endsWith(File.separator)) {
|
||||
baseDirPath += File.separator;
|
||||
}
|
||||
String filePath = file.getAbsolutePath();
|
||||
/**
|
||||
* 测试此抽象路径名表示的文件是否是一个目录。 要是这个文件对象是一个目录 则也要变成 后面带 "/" 这个文件对象类似于
|
||||
* "C:/temp/人体写真/1.jpg" 要是这个文件是一个文件夹 则也要变成 后面带 "/"
|
||||
* 因为你要是不这样做,它也会被压缩到目标文件中 但是却不能正解显示 也就是说操作系统不能正确识别它的文件类型(是文件还是文件夹)
|
||||
*/
|
||||
if (file.isDirectory()) {
|
||||
filePath += "/";
|
||||
}
|
||||
int index = filePath.indexOf(baseDirPath);
|
||||
return filePath.substring(index + baseDirPath.length());
|
||||
}
|
||||
|
||||
// //////////////////////////解压缩////////////////////////////////////////
|
||||
/**
|
||||
* 调用org.apache.tools.zip实现解压缩,支持目录嵌套和中文名
|
||||
* 也可以使用java.util.zip不过如果是中文的话,解压缩的时候文件名字会是乱码
|
||||
* 。原因是解压缩软件的编码格式跟java.util.zip.ZipInputStream的编码字符集(固定是UTF-8)不同
|
||||
*
|
||||
* @param zipFileName
|
||||
* 要解压缩的文件
|
||||
* @param outputDirectory
|
||||
* 要解压到的目录
|
||||
* @throws Exception
|
||||
*/
|
||||
public static boolean unZip(String zipFileName, String outputDirectory) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
org.apache.tools.zip.ZipFile zipFile = new org.apache.tools.zip.ZipFile(
|
||||
zipFileName);
|
||||
java.util.Enumeration e = zipFile.getEntries();
|
||||
org.apache.tools.zip.ZipEntry zipEntry = null;
|
||||
createDirectory(outputDirectory, "");
|
||||
while (e.hasMoreElements()) {
|
||||
zipEntry = (org.apache.tools.zip.ZipEntry) e.nextElement();
|
||||
// System.out.println("unziping " + zipEntry.getName());
|
||||
if (zipEntry.isDirectory()) {
|
||||
String name = zipEntry.getName();
|
||||
name = name.substring(0, name.length() - 1);
|
||||
File f = new File(outputDirectory + File.separator + name);
|
||||
f.mkdir();
|
||||
System.out.println("创建目录:" + outputDirectory
|
||||
+ File.separator + name);
|
||||
} else {
|
||||
String fileName = zipEntry.getName();
|
||||
fileName = fileName.replace('\\', '/');
|
||||
// System.out.println("测试文件1:" +fileName);
|
||||
if (fileName.indexOf("/") != -1) {
|
||||
createDirectory(outputDirectory, fileName.substring(0,
|
||||
fileName.lastIndexOf("/")));
|
||||
fileName = fileName.substring(
|
||||
fileName.lastIndexOf("/") + 1,
|
||||
fileName.length());
|
||||
}
|
||||
|
||||
File f = new File(outputDirectory + File.separator
|
||||
+ zipEntry.getName());
|
||||
|
||||
f.createNewFile();
|
||||
InputStream in = zipFile.getInputStream(zipEntry);
|
||||
FileOutputStream out = new FileOutputStream(f);
|
||||
|
||||
byte[] by = new byte[1024];
|
||||
int c;
|
||||
while ((c = in.read(by)) != -1) {
|
||||
out.write(by, 0, c);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建目录
|
||||
*
|
||||
* @param directory
|
||||
* 父目录
|
||||
* @param subDirectory
|
||||
* 子目录
|
||||
*/
|
||||
private static void createDirectory(String directory, String subDirectory) {
|
||||
String dir[];
|
||||
File fl = new File(directory);
|
||||
try {
|
||||
if (subDirectory == "" && fl.exists() != true)
|
||||
fl.mkdir();
|
||||
else if (subDirectory != "") {
|
||||
dir = subDirectory.replace('\\', '/').split("/");
|
||||
for (int i = 0; i < dir.length; i++) {
|
||||
File subFile = new File(directory + File.separator + dir[i]);
|
||||
if (subFile.exists() == false)
|
||||
subFile.mkdir();
|
||||
directory += File.separator + dir[i];
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void zip(File inputFile) {
|
||||
try {
|
||||
//创建文件输出对象out,提示:注意中文支持
|
||||
FileOutputStream out = new FileOutputStream(inputFile.getAbsolutePath()+".zip");
|
||||
//將文件輸出ZIP输出流接起来
|
||||
ZipOutputStream zOut = new ZipOutputStream(out);
|
||||
|
||||
zip(zOut, inputFile, "");
|
||||
|
||||
zOut.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void zip(ZipOutputStream zOut, File file, String base) {
|
||||
try {
|
||||
// 如果文件句柄是目录
|
||||
if (file.isDirectory()) {
|
||||
// 获取目录下的文件
|
||||
File[] listFiles = file.listFiles();
|
||||
// 建立ZIP条目
|
||||
zOut.putNextEntry(new ZipEntry(base + "/"));
|
||||
|
||||
base = (base.length() == 0 ? "" : base + "/");
|
||||
|
||||
// 遍历目录下文件
|
||||
for (int i = 0; i < listFiles.length; i++) {
|
||||
// 递归进入本方法
|
||||
zip(zOut, listFiles[i], base + listFiles[i].getName());
|
||||
}
|
||||
}
|
||||
// 如果文件句柄是文件
|
||||
else {
|
||||
if (base == "") {
|
||||
base = file.getName();
|
||||
}
|
||||
// 填入文件句柄
|
||||
zOut.putNextEntry(new ZipEntry(base));
|
||||
|
||||
// 开始压缩
|
||||
// 从文件入流读,写入ZIP 出流
|
||||
writeFile(zOut, file);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFile(ZipOutputStream zOut, File file)
|
||||
throws IOException {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
int len;
|
||||
while ((len = in.read()) != -1)
|
||||
zOut.write(len);
|
||||
in.close();
|
||||
}
|
||||
|
||||
// /////////////////////////////////////
|
||||
|
||||
public static void main(String[] temp) {
|
||||
// 压缩
|
||||
// String baseDirName = "C:\\";
|
||||
// String[] fileNames = { "中文1.doc", "中文2.doc" };
|
||||
// String zipFileName = "c:\\中文.zip";
|
||||
// // 压缩多个指定的文件 到ZIP
|
||||
// System.out.println(ZipUtil.zip(baseDirName,
|
||||
// fileNames,zipFileName,"GBK"));
|
||||
|
||||
// 压缩一个文件夹 到ZIP
|
||||
String sourcePath = "G:\\tomcat\\apache-tomcat-7.0.70\\apache-tomcat-7.0.70\\webapps\\mgmt\\attached\\downlaodcache\\2015050608332656789\\2017010516350645638";
|
||||
ZipUtil.zip(new File(sourcePath));
|
||||
|
||||
// 解压缩
|
||||
// System.out.println(ZipUtil.unZip("c:\\中文.zip", "c:\\中文"));
|
||||
}
|
||||
//删除指定文件夹下所有文件
|
||||
//param path 文件夹完整绝对路径
|
||||
public static boolean delAllFile(String path) {
|
||||
boolean flag = false;
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return flag;
|
||||
}
|
||||
if (!file.isDirectory()) {
|
||||
return flag;
|
||||
}
|
||||
String[] tempList = file.list();
|
||||
File temp = null;
|
||||
for (int i = 0; i < tempList.length; i++) {
|
||||
if (path.endsWith(File.separator)) {
|
||||
temp = new File(path + tempList[i]);
|
||||
} else {
|
||||
temp = new File(path + File.separator + tempList[i]);
|
||||
}
|
||||
if (temp.isFile()) {
|
||||
temp.delete();
|
||||
}
|
||||
if (temp.isDirectory()) {
|
||||
delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
|
||||
delFolder(path + "/" + tempList[i]);//再删除空文件夹
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
//删除文件夹
|
||||
//param folderPath 文件夹完整绝对路径
|
||||
|
||||
public static void delFolder(String folderPath) {
|
||||
try {
|
||||
delAllFile(folderPath); //删除完里面所有内容
|
||||
String filePath = folderPath;
|
||||
filePath = filePath.toString();
|
||||
java.io.File myFilePath = new java.io.File(filePath);
|
||||
myFilePath.delete(); //删除空文件夹
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
146
src/main/java/com/util/yzcode/BuilderCode.java
Normal file
146
src/main/java/com/util/yzcode/BuilderCode.java
Normal file
@@ -0,0 +1,146 @@
|
||||
package com.util.yzcode;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
public class BuilderCode extends HttpServlet {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生成图片验证码
|
||||
*
|
||||
* @author dubaohui
|
||||
* @date 2009-6-5
|
||||
*/
|
||||
|
||||
// 验证码图片的宽度。
|
||||
private int width = 60;
|
||||
// 验证码图片的高度。
|
||||
private int height = 32;
|
||||
// 验证码字符个数
|
||||
private int codeCount = 4;
|
||||
private int x = 0;
|
||||
// 字体高度
|
||||
private int fontHeight;
|
||||
private int codeY;
|
||||
|
||||
char[] codeSequence = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
||||
|
||||
/**
|
||||
* 初始化验证图片属性
|
||||
*/
|
||||
public void init() throws ServletException {
|
||||
// 从web.xml中获取初始信息
|
||||
// 宽度
|
||||
String strWidth = this.getInitParameter("width");
|
||||
// 高度
|
||||
String strHeight = this.getInitParameter("height");
|
||||
// 字符个数
|
||||
String strCodeCount = this.getInitParameter("codeCount");
|
||||
|
||||
// 将配置的信息转换成数值
|
||||
try {
|
||||
if (strWidth != null && strWidth.length() != 0) {
|
||||
width = Integer.parseInt(strWidth);
|
||||
}
|
||||
if (strHeight != null && strHeight.length() != 0) {
|
||||
height = Integer.parseInt(strHeight);
|
||||
}
|
||||
if (strCodeCount != null && strCodeCount.length() != 0) {
|
||||
codeCount = Integer.parseInt(strCodeCount);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
x = width / (codeCount + 1);
|
||||
fontHeight = height - 2;
|
||||
codeY = height - 4;
|
||||
|
||||
}
|
||||
|
||||
protected void service(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, java.io.IOException {
|
||||
|
||||
HttpSession session = req.getSession();
|
||||
|
||||
// 定义图像buffer
|
||||
BufferedImage buffImg = new BufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g = buffImg.createGraphics();
|
||||
|
||||
// 创建一个随机数生成器类
|
||||
Random random = new Random();
|
||||
|
||||
// 将图像填充为白色
|
||||
g.setColor(Color.WHITE);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
// 创建字体,字体的大小应该根据图片的高度来定。
|
||||
Font font = new Font("Fixedsys", Font.PLAIN, fontHeight);
|
||||
// 设置字体。
|
||||
g.setFont(font);
|
||||
|
||||
// 画边框。
|
||||
g.setColor(Color.WHITE);
|
||||
g.drawRect(0, 0, width - 1, height - 1);
|
||||
|
||||
// 随机产生20条干扰线,使图象中的认证码不易被其它程序探测到。
|
||||
g.setColor(Color.BLACK);
|
||||
/*for (int i = 0; i < 20; i++) {
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int xl = random.nextInt(12);
|
||||
int yl = random.nextInt(12);
|
||||
g.drawLine(x, y, x + xl, y + yl);
|
||||
}*/
|
||||
|
||||
// randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
|
||||
StringBuffer randomCode = new StringBuffer();
|
||||
int red = 0, green = 0, blue = 0;
|
||||
|
||||
// 随机产生codeCount数字的验证码。
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
// 得到随机产生的验证码数字。
|
||||
String strRand = String.valueOf(codeSequence[random.nextInt(10)]);
|
||||
// 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。
|
||||
red = random.nextInt(255);
|
||||
green = random.nextInt(255);
|
||||
blue = random.nextInt(255);
|
||||
|
||||
// 用随机产生的颜色将验证码绘制到图像中。
|
||||
g.setColor(new Color(red, green, blue));
|
||||
g.drawString(strRand, (i + 1) * x-2, codeY+2);
|
||||
// 将产生的四个随机数组合在一起。
|
||||
randomCode.append(strRand);
|
||||
}
|
||||
// 将四位数字的验证码保存到Session中。
|
||||
session.setAttribute("validateCodeRecruitstu", randomCode.toString());
|
||||
// 禁止图像缓存。
|
||||
resp.setHeader("Pragma", "no-cache");
|
||||
resp.setHeader("Cache-Control", "no-cache");
|
||||
resp.setDateHeader("Expires", 0);
|
||||
resp.setContentType("image/jpeg");
|
||||
//清空缓存
|
||||
g.dispose();
|
||||
// 将图像输出到Servlet输出流中。
|
||||
ServletOutputStream sos = resp.getOutputStream();
|
||||
ImageIO.write(buffImg, "jpeg", sos);
|
||||
sos.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
78
src/main/java/com/zhongdao/jlr/BaiduTest.java
Normal file
78
src/main/java/com/zhongdao/jlr/BaiduTest.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.zhongdao.jlr;
|
||||
|
||||
import com.util.NetUtil;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
//java版计算signature签名
|
||||
public class BaiduTest {
|
||||
public static void main(String[] args) throws UnsupportedEncodingException,
|
||||
NoSuchAlgorithmException {
|
||||
BaiduTest snCal = new BaiduTest();
|
||||
|
||||
// 计算sn跟参数对出现顺序有关,get请求请使用LinkedHashMap保存<key,value>,该方法根据key的插入顺序排序;post请使用TreeMap保存<key,value>,该方法会自动将key按照字母a-z顺序排序。所以get请求可自定义参数顺序(sn参数必须在最后)发送请求,但是post请求必须按照字母a-z顺序填充body(sn参数必须在最后)。以get请求为例:http://api.map.baidu.com/geocoder/v2/?address=百度大厦&output=json&ak=yourak,paramsMap中先放入address,再放output,然后放ak,放入顺序必须跟get请求中对应参数的出现顺序保持一致。
|
||||
Map paramsMap = new LinkedHashMap<String, String>();
|
||||
paramsMap.put("address", "上海市张江路1196号");
|
||||
paramsMap.put("output", "json");
|
||||
paramsMap.put("ak", "F5lGYj8lbIGcZUSym6jIQNnN0ms9sabM");
|
||||
|
||||
// 调用下面的toQueryString方法,对LinkedHashMap内所有value作utf8编码,拼接返回结果address=%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6&output=json&ak=yourak
|
||||
String paramsStr = snCal.toQueryString(paramsMap);
|
||||
|
||||
// 对paramsStr前面拼接上/geocoder/v2/?,后面直接拼接yoursk得到/geocoder/v2/?address=%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6&output=json&ak=yourakyoursk
|
||||
String wholeStr = new String("/geocoder/v2/?" + paramsStr + "4VbjBrpfEfKeFPGc8PfGRIjRmRX8MwWy");
|
||||
|
||||
// 对上面wholeStr再作utf8编码
|
||||
String tempStr = URLEncoder.encode(wholeStr, "UTF-8");
|
||||
|
||||
// 调用下面的MD5方法得到最后的sn签名7de5a22212ffaa9e326444c75a58f9a0
|
||||
String sn=snCal.MD5(tempStr);
|
||||
System.out.println(sn);
|
||||
System.out.println(NetUtil.sendPost("http://api.map.baidu.com/geocoder/v2/?address=上海市张江路1196号&output=json&ak=F5lGYj8lbIGcZUSym6jIQNnN0ms9sabM&sn="+sn, ""));
|
||||
}
|
||||
|
||||
// 对Map内所有value作utf8编码,拼接返回结果
|
||||
public String toQueryString(Map<?, ?> data)
|
||||
throws UnsupportedEncodingException { StringBuffer queryString = new StringBuffer();
|
||||
for (Entry<?, ?> pair : data.entrySet()) {
|
||||
queryString.append(pair.getKey() + "=");
|
||||
String ss[] = pair.getValue().toString().split(",");
|
||||
if(ss.length>1){
|
||||
for(String s:ss){
|
||||
queryString.append(URLEncoder.encode(s,"UTF-8") + ",");
|
||||
}
|
||||
queryString.deleteCharAt(queryString.length()-1);
|
||||
queryString.append("&");
|
||||
}
|
||||
else{
|
||||
queryString.append(URLEncoder.encode((String) pair.getValue(),
|
||||
"UTF-8") + "&");
|
||||
}
|
||||
}
|
||||
if (queryString.length() > 0) {
|
||||
queryString.deleteCharAt(queryString.length() - 1);
|
||||
}
|
||||
return queryString.toString();}
|
||||
|
||||
// 来自stackoverflow的MD5计算方法,调用了MessageDigest库函数,并把byte数组结果转换成16进制
|
||||
public String MD5(String md5) {
|
||||
try {
|
||||
java.security.MessageDigest md = java.security.MessageDigest
|
||||
.getInstance("MD5");
|
||||
byte[] array = md.digest(md5.getBytes());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100)
|
||||
.substring(1, 3));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (java.security.NoSuchAlgorithmException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
55
src/main/java/com/zhongdao/jlr/Test.java
Normal file
55
src/main/java/com/zhongdao/jlr/Test.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.zhongdao.jlr;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
public class Test {
|
||||
// public static void main(String[] args) {
|
||||
// Week week=Week.valueOf("SUN1");
|
||||
// switch (week) {
|
||||
// case SUN:
|
||||
// System.out.println("星期天");
|
||||
// break;
|
||||
// case MON:
|
||||
// System.out.println("星期1");
|
||||
// break;
|
||||
// default:
|
||||
// System.out.println("不是星期内");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
double f = 111231;
|
||||
public void m1() {
|
||||
BigDecimal bg = new BigDecimal(f);
|
||||
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
System.out.println(f1);
|
||||
}
|
||||
/**
|
||||
* DecimalFormat转换最简便
|
||||
*/
|
||||
public void m2() {
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
System.out.println(df.format(f));
|
||||
}
|
||||
/**
|
||||
* String.format打印最简便
|
||||
*/
|
||||
public void m3() {
|
||||
System.out.println(String.format("%.2f", f));
|
||||
}
|
||||
public void m4() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
nf.setMaximumFractionDigits(2);
|
||||
System.out.println(nf.format(f));
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
// Test f = new Test();
|
||||
// f.m1();
|
||||
// f.m2();
|
||||
// f.m3();
|
||||
// f.m4();
|
||||
System.out.println(System.currentTimeMillis()+"");
|
||||
}
|
||||
}
|
||||
106
src/main/java/com/zhongdao/jlr/business/action/BaseAction.java
Normal file
106
src/main/java/com/zhongdao/jlr/business/action/BaseAction.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.zhongdao.jlr.business.service.BaseService;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 用户登录控制器
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base")
|
||||
public class BaseAction {
|
||||
|
||||
@Resource(name = "baseServiceImpl")
|
||||
BaseService baseService;
|
||||
|
||||
/***
|
||||
* 用户登录
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/login.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void login(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String username = request.getParameter("username");
|
||||
String password = request.getParameter("password");
|
||||
Map result = new HashMap();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (TextUtils.isEmpty(username) || TextUtils.isEmpty(password)) {
|
||||
result.put("msg", "必填参数不能为空");
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
return;
|
||||
}
|
||||
Map map = baseService.login(request, result, username, password);
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(map));
|
||||
}
|
||||
|
||||
/***
|
||||
* 展示权限列表
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/home.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String home(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取菜单信息
|
||||
List<BaseMenu> list=baseService.getMenuInfo();
|
||||
//获取父级菜单信息
|
||||
List<BaseMenu> lists=baseService.getParentMenuInfo();
|
||||
//共享数据
|
||||
request.setAttribute("firstPage", 1);
|
||||
request.getSession().setAttribute("menu", list);
|
||||
request.getSession().setAttribute("parentMenu", lists);
|
||||
return "/page/home";
|
||||
}
|
||||
|
||||
/***
|
||||
* 用户注销
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loginout.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String loginout(HttpServletRequest request, HttpServletResponse response) {
|
||||
request.getSession().invalidate();
|
||||
return "/login";
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图定位
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/amap.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String amap(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String lngStr = request.getParameter("lngStr");
|
||||
//将参数类型转换为double类型
|
||||
Double lng = Double.valueOf(TextUtils.isBlank(lngStr) ? 0 : Double.valueOf(lngStr));
|
||||
String StrLat = request.getParameter("lat");
|
||||
Double lat = Double.valueOf(TextUtils.isBlank(StrLat) ? 0 : Double.valueOf(StrLat));
|
||||
//共享数据
|
||||
request.setAttribute("lng", lng);
|
||||
request.setAttribute("lat", lat);
|
||||
return "/page/amap/amap";
|
||||
}
|
||||
}
|
||||
176
src/main/java/com/zhongdao/jlr/business/action/CasesAction.java
Normal file
176
src/main/java/com/zhongdao/jlr/business/action/CasesAction.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
import com.util.RequestUtil;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.CasesListService;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 道路救援控制器
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/casesInfo")
|
||||
public class CasesAction {
|
||||
|
||||
private final static String timeFormat = "yyyy/MM/dd";
|
||||
|
||||
@Resource(name = "casesListServiceImpl")
|
||||
CasesListService casesListService;
|
||||
|
||||
/*
|
||||
* 跳转救援工单页面
|
||||
* */
|
||||
@RequestMapping(value = "/case.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String JumpTocaseInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String state = request.getParameter("state");
|
||||
//共享数据
|
||||
request.setAttribute("state", state);
|
||||
if("0".equals(state)){
|
||||
return "/page/caseInfo";
|
||||
}else {
|
||||
return "/page/sue";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 跳转进店工单页面
|
||||
* */
|
||||
@RequestMapping(value = "/caseEnter.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String caseEnter(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取登录信息
|
||||
LoginUserVo loginInfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
//获取参数
|
||||
String state = request.getParameter("state");
|
||||
//共享数据
|
||||
request.setAttribute("state", state);
|
||||
return "/page/caseInfoEnter";
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取道路救援案件信息
|
||||
* */
|
||||
@RequestMapping(value = "/caseFirstQuery.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseInfoList(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String caseCode = request.getParameter("caseCode");// 案件编号
|
||||
String frame_code = request.getParameter("frame_code");// VIN码
|
||||
String rescueState = request.getParameter("rescueState");// 服务状态
|
||||
String createTime = request.getParameter("createTime");//开始时间
|
||||
String finishTime = request.getParameter("finishTime");//结束时间
|
||||
String companyName = request.getParameter("companyName");//服务商代码
|
||||
String state = request.getParameter("state");//服务商代码
|
||||
String plateNumber = request.getParameter("plateNumber");//服务商代码
|
||||
//获取救援信息
|
||||
Vo vo = casesListService.casesListService(state,request,caseCode,
|
||||
frame_code, rescueState,createTime, finishTime, companyName,plateNumber);
|
||||
//将救援信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取进店救援案件信息
|
||||
* */
|
||||
@RequestMapping(value = "/caseEnterQuery.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseEnterQuery(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String caseCode = request.getParameter("caseCode");// 案件编号
|
||||
String frame_code = request.getParameter("frame_code");// VIN码
|
||||
String createTime = request.getParameter("createTime");//开始时间
|
||||
String finishTime = request.getParameter("finishTime");//结束时间
|
||||
String state = request.getParameter("state");//结束时间
|
||||
//获取进店救援案件信息
|
||||
Vo vo = casesListService.caseEnterQuery(state,request,caseCode,
|
||||
frame_code,createTime, finishTime);
|
||||
//将救援信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/*
|
||||
* 救援案件详情信息
|
||||
* */
|
||||
@RequestMapping(value = "/caseEnterInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String caseEnterInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String caseCode = request.getParameter("code");// 案件编号
|
||||
String tid = request.getParameter("tid");//任务编号
|
||||
String state = request.getParameter("state");//任务编号
|
||||
//获取进店救援案件详情信息
|
||||
Vo vo = casesListService.caseEnterInfo(request,caseCode,tid);
|
||||
//共享数据
|
||||
request.setAttribute("info",vo);
|
||||
request.setAttribute("state",state);
|
||||
//跳转页面
|
||||
return "/page/caseDetail";
|
||||
}
|
||||
|
||||
/*
|
||||
* 故障零件三级检索
|
||||
* */
|
||||
@RequestMapping(value = "/getTroubleCode.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getTroubleCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject jsonObject = casesListService.getTroubleCode(request);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* 案件详细信息保存
|
||||
* */
|
||||
@RequestMapping(value = "/caseDetailSave.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseDetailSave(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject jsonObject = casesListService.caseDetailSave(request);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
*导出数据EXCEl格式
|
||||
* */
|
||||
@RequestMapping(value = "/exportData.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void exportData(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject jsonObject = casesListService.exportData(request);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
*导出数据CSV
|
||||
* */
|
||||
@RequestMapping(value = "/exportDataCSV.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void exportDataCSV(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject jsonObject = casesListService.exportCSVData(request, response);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* 救援完成确认
|
||||
* */
|
||||
@RequestMapping(value = "/completionOfRescue.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void completionOfRescue(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
//获取参数
|
||||
String code = request.getParameter("code");
|
||||
//获取救援详情信息
|
||||
JSON jsonObject = casesListService.completionOfRescue(code);
|
||||
//将json数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(jsonObject));
|
||||
}
|
||||
}
|
||||
299
src/main/java/com/zhongdao/jlr/business/action/CouponAction.java
Normal file
299
src/main/java/com/zhongdao/jlr/business/action/CouponAction.java
Normal file
@@ -0,0 +1,299 @@
|
||||
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.CouponService;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 代金劵控制器
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/coupon")
|
||||
public class CouponAction {
|
||||
|
||||
@Resource(name = "couponServiceImpl")
|
||||
CouponService baseService;
|
||||
|
||||
/**
|
||||
* 账户查询页面
|
||||
*/
|
||||
@RequestMapping(value = "/coupon_history.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public String couponHistory(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/coupon_consume_history";
|
||||
}
|
||||
|
||||
/**
|
||||
* 代金劵搜索
|
||||
*/
|
||||
@RequestMapping(value = "/search_consume.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void searchConsume(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String vinCode = request.getParameter("vinCode");
|
||||
String userPhone = request.getParameter("userPhone");
|
||||
String electronicAccounts = request.getParameter("electronicAccounts");
|
||||
//查询代金券数据
|
||||
Vo list = baseService.searchConsume(vinCode, electronicAccounts,userPhone, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人代金券消费记录
|
||||
*/
|
||||
|
||||
@RequestMapping(value = "/get_coupon_consume.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void getCouponConsume(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String vin = request.getParameter("vinCode");
|
||||
if (!TextUtils.isEmpty(vin)) {
|
||||
//获取个人代金券消费信息
|
||||
Vo vo = baseService.getCouponConsume(vin, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
|
||||
} else {
|
||||
RequestUtil.responseResult4JsonError(response, "参数为空");
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人充值记录
|
||||
*/
|
||||
@RequestMapping(value = "/get_coupon_recharge.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void getCouponRecharge(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String vin = request.getParameter("vinCode");
|
||||
if (!TextUtils.isEmpty(vin)) {
|
||||
//获取用户充值记录
|
||||
Vo vo = baseService.getCouponRecharge(vin, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
//将用户充值记录信息发送到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
} else {
|
||||
RequestUtil.responseResult4JsonError(response, "参数为空");
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费记录查询、处理页面
|
||||
*/
|
||||
@RequestMapping(value = "/consume_query.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET})
|
||||
public String couponConsumeQuery(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String state = request.getParameter("state");
|
||||
//共享数据
|
||||
request.setAttribute("state",state);
|
||||
return "/page/coupon_consume_query";
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费记录查询、处理页面
|
||||
*/
|
||||
@RequestMapping(value = "/consume_querys.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.POST})
|
||||
public void getConsumeQuery(@RequestParam(value = "vininput", required = false, defaultValue = "") String vin,
|
||||
@RequestParam(value = "electronicAccounts", required = false, defaultValue = "") String account,
|
||||
@RequestParam(value = "license", required = false, defaultValue = "") String license,
|
||||
@RequestParam(value = "phone", required = false, defaultValue = "") String phone,
|
||||
@RequestParam(value = "rescueCompanyName", required = false, defaultValue = "") String rescueCompanyName,
|
||||
@RequestParam(value = "queryDate1", required = false, defaultValue = "") String queryDate1,
|
||||
@RequestParam(value = "queryDate2", required = false, defaultValue = "") String queryDate2,
|
||||
@RequestParam(value = "checkState", required = false, defaultValue = "") String checkState,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取session信息
|
||||
LoginUserVo logininfo = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
String rescueCompanyCode = "";
|
||||
if (logininfo.getEnterpriseJlrId() != null) rescueCompanyCode = logininfo.getEnterpriseJlrId().toString();
|
||||
//查询用户消费记录信息并发送到客户端
|
||||
Vo vo = baseService.queryCouponConsume(vin, account, rescueCompanyName, rescueCompanyCode, license, phone, checkState, queryDate1, queryDate2, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出消费记录报表
|
||||
*/
|
||||
@RequestMapping(value = "/exportData.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST}
|
||||
)
|
||||
public void exportData(@RequestParam(value = "vininput", required = false, defaultValue = "") String vin,
|
||||
@RequestParam(value = "electronicAccounts", required = false, defaultValue = "") String account,
|
||||
@RequestParam(value = "license", required = false, defaultValue = "") String license,
|
||||
@RequestParam(value = "phone", required = false, defaultValue = "") String phone,
|
||||
@RequestParam(value = "rescueCompanyName", required = false, defaultValue = "") String rescueCompanyName,
|
||||
@RequestParam(value = "queryDate1", required = false, defaultValue = "") String queryDate1,
|
||||
@RequestParam(value = "queryDate2", required = false, defaultValue = "") String queryDate2,
|
||||
@RequestParam(value = "checkState", required = false, defaultValue = "") String checkState, HttpServletRequest request, HttpServletResponse response) {
|
||||
JSONObject jsonObject = null;
|
||||
//获取session数据
|
||||
LoginUserVo logininfo = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
try {
|
||||
String rescueCompanyCode = "";
|
||||
//获取导出的报表信息
|
||||
if (logininfo.getEnterpriseJlrId() != null) rescueCompanyCode = logininfo.getEnterpriseJlrId().toString();
|
||||
jsonObject = baseService.exportData(request, vin, account, rescueCompanyName, rescueCompanyCode, license, phone, checkState, queryDate1, queryDate2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//将报表信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费记录查询、处理页面
|
||||
*/
|
||||
@RequestMapping(value = "/consume_update.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.POST})
|
||||
public void updateConsumeState(@RequestParam(value = "ids", required = false, defaultValue = "") String ids,
|
||||
@RequestParam(value = "state", required = false, defaultValue = "") String state,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
//修改消费记录的状态
|
||||
Boolean b = baseService.updateConsumeState(ids, state);
|
||||
//将修改记录的状态响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(b));
|
||||
}
|
||||
|
||||
/**
|
||||
* 代金卷账户密码短信发送
|
||||
*/
|
||||
@RequestMapping(value = "/sendMsg.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void sendMsg(HttpServletRequest request, HttpServletResponse response) {
|
||||
String phoneNum = request.getParameter("phoneNum");
|
||||
String msgContent = request.getParameter("msgContent");
|
||||
phoneNum = phoneNum == null ? "" : phoneNum;
|
||||
msgContent = msgContent == null ? "" : msgContent;
|
||||
boolean sign = baseService.sendMsg(phoneNum, msgContent);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("sign", sign);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值记录查询页面
|
||||
*/
|
||||
@RequestMapping(value = "/recharge_query.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET})
|
||||
public String couponRechargeQuery(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/coupon_recharge_query";
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值记录查询、处理页面
|
||||
*/
|
||||
@RequestMapping(value = "/recharges_query.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.POST})
|
||||
public void getRechargeQuery(@RequestParam(value = "vininput", required = false, defaultValue = "") String vin,
|
||||
@RequestParam(value = "electronicAccounts", required = false, defaultValue = "") String account,
|
||||
@RequestParam(value = "license", required = false, defaultValue = "") String license,
|
||||
@RequestParam(value = "phone", required = false, defaultValue = "") String phone,
|
||||
@RequestParam(value = "orderCode", required = false, defaultValue = "") String orderCode,
|
||||
@RequestParam(value = "queryDate1", required = false, defaultValue = "") String queryDate1,
|
||||
@RequestParam(value = "queryDate2", required = false, defaultValue = "") String queryDate2,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
Vo vo = baseService.queryCouponRecharge(vin, account, orderCode, license, phone, queryDate1, queryDate2, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出充值记录报表
|
||||
*/
|
||||
@RequestMapping(value = "/rechangeExportData.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void rechangeExportData(@RequestParam(value = "vininput", required = false, defaultValue = "") String vin,
|
||||
@RequestParam(value = "electronicAccounts", required = false, defaultValue = "") String account,
|
||||
@RequestParam(value = "phone", required = false, defaultValue = "") String phone,
|
||||
@RequestParam(value = "orderCode", required = false, defaultValue = "") String orderCode,
|
||||
@RequestParam(value = "queryDate1", required = false, defaultValue = "") String queryDate1,
|
||||
@RequestParam(value = "queryDate2", required = false, defaultValue = "") String queryDate2,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
//获取充值记录的报表信息
|
||||
jsonObject = baseService.rechangeExportData(request, vin, account, orderCode, phone, queryDate1, queryDate2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//将报表信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 代金劵消费页面
|
||||
*/
|
||||
@RequestMapping(value = "/coupon_consume.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public String couponConsume(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/coupon_consume";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人账户信息
|
||||
*/
|
||||
@RequestMapping(value = "/get_coupon.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void getCoupon(HttpServletRequest request, HttpServletResponse response) {
|
||||
String vin = request.getParameter("vin");
|
||||
String electronicAccounts = request.getParameter("electronicAccounts");
|
||||
|
||||
if (!TextUtils.isEmpty(vin) || !TextUtils.isEmpty(electronicAccounts)) {
|
||||
Vo list = baseService.getCoupon(vin, electronicAccounts, UtilTools.getPage(request), UtilTools.getRows(request));
|
||||
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(list));
|
||||
} else {
|
||||
RequestUtil.responseResult4JsonError(response, "参数为空");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 代金劵消费
|
||||
*/
|
||||
@RequestMapping(value = "/consume.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void consume(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,用来存储返回的结果集
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "消费失败");
|
||||
//获取参数
|
||||
String vinCode = request.getParameter("vinCode");
|
||||
String consumeCount = request.getParameter("consumeCount");
|
||||
String remark = request.getParameter("remark");
|
||||
String epassword = request.getParameter("epassword");
|
||||
String consumeTime = request.getParameter("consumeTime");
|
||||
String reparieInfo = request.getParameter("reparieInfo");
|
||||
String hitchInfo = request.getParameter("hitchInfo");
|
||||
//获取用户信息
|
||||
LoginUserVo loginuser = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
//若用户为空则返回错误信息
|
||||
if (loginuser == null) {
|
||||
result.put("msg", "没有登录");
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(consumeTime) && !TextUtils.isEmpty(vinCode) && !TextUtils.isEmpty(consumeCount) && !TextUtils.isEmpty(epassword)) {
|
||||
Map back = baseService.consume(consumeTime, vinCode, Double.valueOf(consumeCount), Integer.valueOf(loginuser.getEnterpriseJlrId()), reparieInfo, hitchInfo, remark, epassword);
|
||||
if ((boolean) back.get("status")) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "消费成功");
|
||||
} else {
|
||||
result.put("msg", back.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.EnterpriseService;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 经销商维护控制器
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/enterprise")
|
||||
public class EnterpriseAction {
|
||||
|
||||
@Resource(name = "enterpriseServiceImpl")
|
||||
EnterpriseService baseService;
|
||||
|
||||
/**
|
||||
* 经销商维护列表页面
|
||||
*/
|
||||
@RequestMapping(value = "/enterprise.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String enterprise(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/enterprise";
|
||||
}
|
||||
|
||||
/**
|
||||
* 经销商维护搜索
|
||||
*/
|
||||
@RequestMapping(value = "/search_enterprise.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void searchEnterprise(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");
|
||||
String abbrCode = request.getParameter("abbrCode");
|
||||
//获取经销商信息
|
||||
Vo list = baseService.searchEnterprise(name, abbrCode, UtilTools.getPage(request), UtilTools
|
||||
.getRows(request));
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号删除经销商信息
|
||||
*/
|
||||
@RequestMapping(value = "/delete_by_id.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void deleteById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map对象用于存放响应到客户端的数据
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String id = request.getParameter("id");
|
||||
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据编号删除经销商信息
|
||||
boolean back = baseService.deleteById(id);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 经销商信息修改
|
||||
*/
|
||||
@RequestMapping(value = "/put_enterprise.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void putMyEnterprise(HttpServletRequest request, HttpServletResponse response, @ModelAttribute EnterpriseJlr
|
||||
enterprise) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String name = request.getParameter("name");
|
||||
String abbrCode = request.getParameter("abbr_code");
|
||||
String brands = request.getParameter("brands");
|
||||
String contact = request.getParameter("contact");
|
||||
String phone1 = request.getParameter("phone1");
|
||||
String job1 = request.getParameter("job1");
|
||||
String newPassword = request.getParameter("newPassword");
|
||||
String confirmPassword = request.getParameter("confirmPassword");
|
||||
String contact2 = request.getParameter("contact2");
|
||||
String phone2 = request.getParameter("phone2");
|
||||
String job2 = request.getParameter("job2");
|
||||
String contact3 = request.getParameter("contact3");
|
||||
String phone3 = request.getParameter("phone3");
|
||||
String job3 = request.getParameter("job3");
|
||||
//遍历服务资质信息并将其拼接
|
||||
String[] serviceQualifications = request.getParameterValues("service_qualification");
|
||||
StringBuffer serviceQualification=new StringBuffer();
|
||||
for(String service:serviceQualifications){
|
||||
serviceQualification.append(service);
|
||||
serviceQualification.append(",");
|
||||
}
|
||||
String serviceQualificationer=serviceQualification.subSequence(0,serviceQualification.lastIndexOf(",")).toString();
|
||||
String address = request.getParameter("address");
|
||||
String vinCode = request.getParameter("vin_code");
|
||||
String carType = request.getParameter("car_type");
|
||||
String firstSellDate = request.getParameter("first_sale_date");
|
||||
String lon = request.getParameter("lon");
|
||||
String lat = request.getParameter("lat");
|
||||
String id = request.getParameter("id");
|
||||
// 防止数据累加
|
||||
if (enterprise != null) {
|
||||
enterprise.setName(name);
|
||||
enterprise.setAbbr_code(abbrCode);
|
||||
enterprise.setBrands(brands);
|
||||
enterprise.setContact(contact);
|
||||
enterprise.setPhone1(phone1);
|
||||
enterprise.setJob1(job1);
|
||||
enterprise.setContact2(contact2);
|
||||
enterprise.setPhone2(phone2);
|
||||
enterprise.setJob2(job2);
|
||||
enterprise.setContact3(contact3);
|
||||
enterprise.setPhone3(phone3);
|
||||
enterprise.setJob3(job3);
|
||||
enterprise.setAddress(address);
|
||||
enterprise.setVin_code(vinCode);
|
||||
enterprise.setCar_type(carType);
|
||||
enterprise.setFirst_sale_date(firstSellDate);
|
||||
enterprise.setLon(lon);
|
||||
enterprise.setLat(lat);
|
||||
enterprise.setService_qualification(serviceQualificationer);
|
||||
//如果id不为空则判断此操作为更改
|
||||
if(!TextUtils.isEmpty(id)){
|
||||
//根据id获取经销商信息
|
||||
EnterpriseJlr back = baseService.getById(id);
|
||||
//获取创建时间并放入enterprise对象中
|
||||
enterprise.setCreate_time(back.getCreate_time());
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(brands) && !TextUtils.isEmpty(abbrCode)) {
|
||||
//添加或更改经销商信息
|
||||
boolean back = baseService.putEnterprise(enterprise, newPassword, confirmPassword,null);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 经销商个人信息修改
|
||||
*/
|
||||
@RequestMapping(value = "/put_Myenterprise.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void put_Myenterprise(HttpServletRequest request, HttpServletResponse response, @ModelAttribute EnterpriseJlr
|
||||
enterprise) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String name = request.getParameter("name");
|
||||
String abbrCode = request.getParameter("abbr_code");
|
||||
String brands = request.getParameter("brands");
|
||||
String contact = request.getParameter("contact");
|
||||
String phone1 = request.getParameter("phone1");
|
||||
String job1 = request.getParameter("job1");
|
||||
String newPassword = request.getParameter("newPassword");
|
||||
String confirmPassword = request.getParameter("confirmPassword");
|
||||
String contact2 = request.getParameter("contact2");
|
||||
String phone2 = request.getParameter("phone2");
|
||||
String job2 = request.getParameter("job2");
|
||||
String contact3 = request.getParameter("contact3");
|
||||
String phone3 = request.getParameter("phone3");
|
||||
String job3 = request.getParameter("job3");
|
||||
String address = request.getParameter("address");
|
||||
String vinCode = request.getParameter("vin_code");
|
||||
String carType = request.getParameter("car_type");
|
||||
String firstSellDate = request.getParameter("first_sale_date");
|
||||
String lon = request.getParameter("lon");
|
||||
String lat = request.getParameter("lat");
|
||||
// 防止数据累加
|
||||
if (enterprise != null) {
|
||||
enterprise.setName(name);
|
||||
enterprise.setAbbr_code(abbrCode);
|
||||
enterprise.setBrands(brands);
|
||||
enterprise.setContact(contact);
|
||||
enterprise.setPhone1(phone1);
|
||||
enterprise.setJob1(job1);
|
||||
enterprise.setContact2(contact2);
|
||||
enterprise.setPhone2(phone2);
|
||||
enterprise.setJob2(job2);
|
||||
enterprise.setContact3(contact3);
|
||||
enterprise.setPhone3(phone3);
|
||||
enterprise.setJob3(job3);
|
||||
enterprise.setAddress(address);
|
||||
enterprise.setVin_code(vinCode);
|
||||
enterprise.setCar_type(carType);
|
||||
enterprise.setFirst_sale_date(firstSellDate);
|
||||
enterprise.setLon(lon);
|
||||
enterprise.setLat(lat);
|
||||
}
|
||||
//获取session数据
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
String enpterpriseId=String.valueOf(logininfo.getEnterpriseJlrId());
|
||||
//根据id获取经销商信息
|
||||
EnterpriseJlr back = baseService.getById(enpterpriseId);
|
||||
enterprise.setId(logininfo.getEnterpriseJlrId());
|
||||
enterprise.setService_qualification(back.getService_qualification());
|
||||
//获取创建时间并放入enterprise对象中
|
||||
enterprise.setCreate_time(back.getCreate_time());
|
||||
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(brands) && !TextUtils.isEmpty(abbrCode)) {
|
||||
//更改个人经销商信息
|
||||
boolean backs = baseService.putEnterprise(enterprise, newPassword, confirmPassword,String.valueOf(logininfo.getId()));
|
||||
if (backs) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询经销商
|
||||
*/
|
||||
@RequestMapping(value = "/get_by_id.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取经销商信息
|
||||
EnterpriseJlr back = baseService.getById(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}
|
||||
} else {
|
||||
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自己的经销商信息
|
||||
*/
|
||||
@RequestMapping(value = "/get_my_info.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getMyInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
LoginUserVo loginuser = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
String id = loginuser.getEnterpriseJlrId() + "";
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
EnterpriseJlr back = baseService.getById(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}else {
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "暂无经销商信息");
|
||||
}
|
||||
} else {
|
||||
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出报表
|
||||
*/
|
||||
@RequestMapping(value = "/exportData.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void exportData(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");
|
||||
String abbrCode = request.getParameter("abbrCode");
|
||||
//获取经销商信息
|
||||
JSONObject jsonObject = baseService.expordata(request, name, abbrCode);
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.OrderCheckService;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/****
|
||||
* 服务结算控制器
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/orderCheck")
|
||||
public class OrderCheckAction {
|
||||
|
||||
@Resource(name = "orderCheckServiceImpl")
|
||||
OrderCheckService serviceImpl;
|
||||
|
||||
/**
|
||||
* 跳转到中道服务核对界面
|
||||
*/
|
||||
@RequestMapping(value = "/list.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public String list(HttpServletRequest request, HttpServletResponse response) {
|
||||
String state = request.getParameter("state");
|
||||
return "/page/orderCheck";
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到中道服务结算界面
|
||||
*/
|
||||
@RequestMapping(value = "/settle.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public String settle(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String state = request.getParameter("state");
|
||||
//共享数据
|
||||
request.setAttribute("state",state);
|
||||
return "/page/orderCheckAll";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询服务费用核对信息
|
||||
*/
|
||||
@RequestMapping(value = "/query.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void query(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String orderCode = request.getParameter("orderCode");
|
||||
String queryDate1 = request.getParameter("queryDate1");
|
||||
String queryDate2 = request.getParameter("queryDate2");
|
||||
String rescueCompanyName = request.getParameter("rescueCompanyName");
|
||||
String checkState = request.getParameter("checkState");
|
||||
//获取工单服务费用信息
|
||||
Vo vo = serviceImpl.list(request, UtilTools.getPage(request), UtilTools.getRows(request),orderCode, queryDate1, rescueCompanyName, queryDate2, checkState);
|
||||
//RequestUtil.responseResult4Json(response, "1");
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询工单费用信息
|
||||
*/
|
||||
@RequestMapping(value = "/querys.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void querys(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String code = request.getParameter("code");
|
||||
String orderCode = request.getParameter("orderCode");
|
||||
String queryDate1 = request.getParameter("queryDate1");
|
||||
String queryDate2 = request.getParameter("queryDate2");
|
||||
String rescueCompanyName = request.getParameter("rescueCompanyName");
|
||||
String checkState = request.getParameter("checkState");
|
||||
String state = request.getParameter("state");
|
||||
//获取工单服务费用信息
|
||||
Vo vo = serviceImpl.lists(request, UtilTools.getPage(request), UtilTools.getRows(request), code, orderCode, queryDate1, rescueCompanyName, queryDate2, checkState,state);
|
||||
//RequestUtil.responseResult4Json(response, "1");
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/***
|
||||
* 导出
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportData.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.POST})
|
||||
public void exportData(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String code = request.getParameter("code");
|
||||
String orderCode = request.getParameter("orderCode");
|
||||
String queryDate1 = request.getParameter("queryDate1");
|
||||
String queryDate2 = request.getParameter("queryDate2");
|
||||
String rescueCompanyName = request.getParameter("rescueCompanyName");
|
||||
String checkState = request.getParameter("checkState");
|
||||
JSONObject jsonObject = serviceImpl.exportData(request, code, orderCode, queryDate1, rescueCompanyName, queryDate2, checkState);
|
||||
RequestUtil.responseResult4Json(response, jsonObject.toString());
|
||||
}
|
||||
|
||||
/***
|
||||
* 保存核对后信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/save.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void save(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String uid = request.getParameter("uid");
|
||||
String totalFee = request.getParameter("totalFee");
|
||||
Map result = new HashMap();
|
||||
result.put("flag", "0");
|
||||
if (StringUtils.isNotBlank(totalFee) && StringUtils.isNotBlank(uid)) {
|
||||
boolean state=serviceImpl.updateInfo(uid,totalFee);
|
||||
if(state){
|
||||
result.put("flag","1");
|
||||
}
|
||||
}else{
|
||||
result.put("msg","参数为空");
|
||||
}
|
||||
RequestUtil.responseResult4Json(response,RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
}
|
||||
177
src/main/java/com/zhongdao/jlr/business/action/RoleAction.java
Normal file
177
src/main/java/com/zhongdao/jlr/business/action/RoleAction.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.RoleService;
|
||||
import com.zhongdao.jlr.business.vo.JLRMenu;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 角色控制器
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/role")
|
||||
public class RoleAction {
|
||||
|
||||
@Resource(name = "roleServiceImpl")
|
||||
RoleService service;
|
||||
|
||||
/***
|
||||
* 跳转角色管理界面
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/role.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String JumpTocaseInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/role";
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取角色信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getRole.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseInfoList(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");// 案件编号
|
||||
//获取用户信息
|
||||
Vo vo = service.getRoleInfo(request, name);
|
||||
//将用户信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取tree数据
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getTree.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getTreeInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取用户信息
|
||||
List<JLRMenu> vo = service.getTreeInfo();
|
||||
//将用户信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ListtoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色信息
|
||||
*/
|
||||
@RequestMapping(value = "/insertRole.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map putMyEnterprise(HttpServletRequest request, HttpServletResponse response, JLRRole jlrRole, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (jlrRole != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = service.updateRoleInfo(jlrRole, ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询角色信息
|
||||
*/
|
||||
@RequestMapping(value = "/getRoleInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取角色信息
|
||||
JLRRole back = service.getRole(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询菜单信息
|
||||
*/
|
||||
@RequestMapping(value = "/getMenuInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getMenu(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取角色信息
|
||||
List<BaseMenu> back = service.getMenu(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号删除角色信息
|
||||
*/
|
||||
@RequestMapping(value = "/deleteRole.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void deleteById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map对象用于存放响应到客户端的数据
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String id = request.getParameter("id");
|
||||
String name = request.getParameter("name");
|
||||
if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(name)) {
|
||||
boolean back = service.deleteRole(id,name);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.SupplierService;
|
||||
import com.zhongdao.jlr.business.service.UserInfoService;
|
||||
import com.zhongdao.jlr.business.vo.Contract;
|
||||
import com.zhongdao.jlr.business.vo.Destination;
|
||||
import com.zhongdao.jlr.business.vo.Enterprise;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUserContract;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/supplier")
|
||||
public class SupplierAction {
|
||||
|
||||
@Resource(name = "userInfoService")
|
||||
UserInfoService service;
|
||||
|
||||
@Resource(name = "supplierServiceImpl")
|
||||
SupplierService serviceImpl;
|
||||
|
||||
/***
|
||||
* 获取用户信息,跳转数据权限管理页面
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/supplier.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String JumpTocaseInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取角色信息
|
||||
List<JLRRole> baseRoles=service.getRoleInfo();
|
||||
//共享数据
|
||||
request.setAttribute("roles",baseRoles);
|
||||
return "/page/supplier";
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取合同信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getContractInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseInfoList(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");// 合同名称
|
||||
String id = request.getParameter("id");// 用户id
|
||||
//获取合同信息
|
||||
Vo vo = serviceImpl.getContractInfo(request,name,id);
|
||||
//将合同信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取指定的合同信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/geAssignContract.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public List<Contract> geAssignContract(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String id = request.getParameter("id");// 用户id
|
||||
//获取合同信息
|
||||
List<Contract> vo = serviceImpl.getAssignContract(id);
|
||||
//将数据响应到客户端
|
||||
return vo;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取指定的目的地信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/geAssignDestination.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public List<Destination> geAssignDestination(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String id = request.getParameter("id");// 用户id
|
||||
//获取合同信息
|
||||
List<Destination> vo = serviceImpl.geAssignDestination(id);
|
||||
//将数据响应到客户端
|
||||
return vo;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取指定的供应商信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/geAssignEnterprise.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public List<Enterprise> geAssignEnterprise(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String id = request.getParameter("id");// 用户id
|
||||
//获取合同信息
|
||||
List<Enterprise> vo = serviceImpl.geAssignEnterprise(id);
|
||||
//将数据响应到客户端
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 获取供应商信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getEnterpriseInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getEnterpriseInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");// 合同名称
|
||||
String id = request.getParameter("id");// 用户id
|
||||
//获取供应商信息
|
||||
Vo vo = serviceImpl.getEnterpriseInfo(request,name,id);
|
||||
//将用户信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取合同下的目的地信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getDestination.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getList(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");// 合同名称
|
||||
String id= request.getParameter("id");// 合同名称
|
||||
//获取合同下的目的地信息
|
||||
Vo vo = serviceImpl.getDestination(request,name,id);
|
||||
//将目的地信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定合同
|
||||
*/
|
||||
@RequestMapping(value = "/insertContract.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map putMyEnterprise(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加合同信息
|
||||
boolean back = serviceImpl.insertContractInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 指定目的地
|
||||
*/
|
||||
@RequestMapping(value = "/insertDestination.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map insertDestination(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = serviceImpl.insertDestinationInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定供应商
|
||||
*/
|
||||
@RequestMapping(value = "/insertEnterprise.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map insertEnterprise(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = serviceImpl.insertEnterpriseInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的合同
|
||||
*/
|
||||
@RequestMapping(value = "/deleteContract.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map deleteContract(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = serviceImpl.deleteContractInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的供应商
|
||||
*/
|
||||
@RequestMapping(value = "/deleteEnterprise.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map deleteEnterprise(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = serviceImpl.deleteEnterpriseInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的目的地
|
||||
*/
|
||||
@RequestMapping(value = "/deleteDestination.do", produces = "application/json;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public Map deleteDestination(HttpServletRequest request, HttpServletResponse response, Integer id, int[] ids) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
if (ids != null && id != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = serviceImpl.deleteDestinationInfo(id,ids);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
}else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id查询合同信息
|
||||
*/
|
||||
@RequestMapping(value = "/getDestinationInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取合同信息
|
||||
List<JLRUserContract> back = serviceImpl.getDestinationInfo(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
227
src/main/java/com/zhongdao/jlr/business/action/UserAction.java
Normal file
227
src/main/java/com/zhongdao/jlr/business/action/UserAction.java
Normal file
@@ -0,0 +1,227 @@
|
||||
package com.zhongdao.jlr.business.action;
|
||||
|
||||
import com.util.RequestUtil;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.service.UserInfoService;
|
||||
import com.zhongdao.jlr.pojo.*;
|
||||
import jodd.util.BCrypt;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 用户管理控制器
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class UserAction {
|
||||
@Resource(name = "userInfoService")
|
||||
UserInfoService service;
|
||||
|
||||
/***
|
||||
* 获取角色信息,跳转用户管理页面
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/user.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String JumpTocaseInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取角色信息
|
||||
List<JLRRole> baseRoles=service.getRoleInfo();
|
||||
//获取经销商信息
|
||||
List<EnterpriseJlr> enterpriseJlrs=service.getEnterpriseInfo();
|
||||
//共享数据
|
||||
request.setAttribute("roles",baseRoles);
|
||||
request.setAttribute("enterprise",enterpriseJlrs);
|
||||
return "/page/user";
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取,跳转用户账号页面
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/myself.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public String JumpMyself(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "/page/modifyPassword";
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取用户信息
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/getUserInfo.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void caseInfoList(HttpServletRequest request, HttpServletResponse response) {
|
||||
//获取参数
|
||||
String name = request.getParameter("name");// 案件编号
|
||||
String phone = request.getParameter("phone");// VIN码
|
||||
String role = request.getParameter("role");// VIN码
|
||||
String username = request.getParameter("username");// VIN码
|
||||
//获取用户信息
|
||||
Vo vo = service.getUserInfo(request,name,phone,role,username);
|
||||
//将用户信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息添加或修改信息修改
|
||||
*/
|
||||
@RequestMapping(value = "/insertUser.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void putMyEnterprise(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JLRUser jlrUser=new JLRUser();
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String name = request.getParameter("name");
|
||||
String username = request.getParameter("login_name");
|
||||
String phone = request.getParameter("phone");
|
||||
String email = request.getParameter("email");
|
||||
String role = request.getParameter("role");
|
||||
String enterprise = request.getParameter("enterprise");
|
||||
String newPassword = request.getParameter("newPassword");
|
||||
String id = request.getParameter("id");
|
||||
//将参数放入对象中
|
||||
if(!TextUtils.isEmpty(id)){
|
||||
jlrUser.setId(Integer.valueOf(id));
|
||||
}
|
||||
jlrUser.setName(name);
|
||||
jlrUser.setLogin_name(username);
|
||||
jlrUser.setPhone(phone);
|
||||
jlrUser.setEmail(email);
|
||||
jlrUser.setPassword(newPassword);
|
||||
jlrUser.setRole_id(Integer.valueOf(role));
|
||||
jlrUser.setEnterprise_id(Integer.valueOf(enterprise));
|
||||
if (jlrUser != null) {
|
||||
//添加或更改用户信息
|
||||
boolean back = service.updateUserInfo(jlrUser);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询用户信息
|
||||
*/
|
||||
@RequestMapping(value = "/getUser.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void getById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取用户信息
|
||||
JLRUser back = service.getUser(id);
|
||||
if (back != null) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
result.put("data", back);
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将结果信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号删除用户信息
|
||||
*/
|
||||
@RequestMapping(value = "/deleteUser.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void deleteById(HttpServletRequest request, HttpServletResponse response) {
|
||||
//声明一个map对象用于存放响应到客户端的数据
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
//根据id获取用户信息
|
||||
JLRUser user = service.getUser(id);
|
||||
//根据编号删除经用户信息
|
||||
boolean back = service.deleteUser(user);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据信息响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@RequestMapping(value = "/updatePassword.do", produces = "text/html;chrset=UTF-8", method = {RequestMethod.GET,
|
||||
RequestMethod.POST})
|
||||
public void updatePassword(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
//声明一个map集合,存储返回的结果信息
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("flag", "0");
|
||||
result.put("msg", "执行失败");
|
||||
//获取参数
|
||||
String password = request.getParameter("password");
|
||||
String newPassword = request.getParameter("newPassword");
|
||||
String confirmPassword = request.getParameter("confirmPassword");
|
||||
String id = request.getParameter("id");
|
||||
if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(password) && !TextUtils.isEmpty(newPassword) && !TextUtils.isEmpty(confirmPassword)) {
|
||||
try {
|
||||
//根据id获取用户信息
|
||||
JLRUser jlrUser=service.getUser(id);
|
||||
if(jlrUser != null){
|
||||
//判断密码是否正确
|
||||
boolean ps= BCrypt.checkpw(password,jlrUser.getPassword());
|
||||
if(ps){
|
||||
//将新密码放入对象中
|
||||
jlrUser.setPassword(newPassword);
|
||||
//修改密码
|
||||
boolean back = service.updateUserInfo(jlrUser);
|
||||
if (back) {
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "执行成功");
|
||||
}
|
||||
}else{
|
||||
throw new Exception("密码错误");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
result.put("msg",e.getMessage());
|
||||
}
|
||||
} else {
|
||||
result.put("msg", "参数为空");
|
||||
}
|
||||
//将数据响应到客户端
|
||||
RequestUtil.responseResult4Json(response, RequestUtil.ObjecttoJsonString(result));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
25
src/main/java/com/zhongdao/jlr/business/dao/BaseDao.java
Normal file
25
src/main/java/com/zhongdao/jlr/business/dao/BaseDao.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface BaseDao extends Dao{
|
||||
|
||||
/***
|
||||
* 获取子菜单信息
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getMenuInfo();
|
||||
|
||||
/***
|
||||
* 获取父级菜单信息
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getParentMenuInfo();
|
||||
}
|
||||
48
src/main/java/com/zhongdao/jlr/business/dao/CaseDao.java
Normal file
48
src/main/java/com/zhongdao/jlr/business/dao/CaseDao.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.UserOrderViewVO;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
public interface CaseDao extends Dao {
|
||||
|
||||
/**
|
||||
* 救援工单信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
Vo casesListService(String state,HttpServletRequest request, String caseCode, String frame_code, String
|
||||
rescueState,String createTime, String finishTime, String companyName,String plateNumber);
|
||||
|
||||
/***
|
||||
* 获取进店救援案件信息
|
||||
* @param request
|
||||
* @param caseCode
|
||||
* @param frame_code
|
||||
* @param createTime
|
||||
* @param finishTime
|
||||
* @return
|
||||
*/
|
||||
Vo caseEnterQuery(String state,HttpServletRequest request,String caseCode,String frame_code,String createTime,String finishTime);
|
||||
|
||||
/****
|
||||
* 获取案件详情信息
|
||||
* @return
|
||||
*/
|
||||
Vo caseEnterInfo(HttpServletRequest request,String caseCode,String tid);
|
||||
|
||||
/*
|
||||
* 故障三级信息
|
||||
*/
|
||||
JSONObject getTroubleCode(HttpServletRequest request) throws Exception;
|
||||
|
||||
/*
|
||||
* 详细页面保存
|
||||
*/
|
||||
JSONObject caseDetailSave(HttpServletRequest request) throws Exception;
|
||||
}
|
||||
53
src/main/java/com/zhongdao/jlr/business/dao/CouponDao.java
Normal file
53
src/main/java/com/zhongdao/jlr/business/dao/CouponDao.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.CouponRechargeJlr;
|
||||
import com.zhongdao.jlr.pojo.CouponConsumeJlrPO;
|
||||
import com.zhongdao.jlr.pojo.CouponRechargeJlrPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CouponDao extends Dao {
|
||||
|
||||
/**
|
||||
* 代金券模糊搜索
|
||||
*/
|
||||
public Vo searchConsume(String vinCode, String electronicAccounts, String userPhone, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费记录
|
||||
*/
|
||||
public Vo getCouponConsume(String vin, int page, int raws);
|
||||
|
||||
|
||||
/**
|
||||
* 代金券充值记录
|
||||
*/
|
||||
public Vo getCouponRecharge(String vin, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费记录(整体)
|
||||
*/
|
||||
public Vo queryCouponConsume(String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String qureyDate1, String queryDate2, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费修改 撤回、同意付款
|
||||
*/
|
||||
public boolean updateConsumeState(List<CouponRechargeJlrPO> couponechargeList, String cId, String state);
|
||||
|
||||
/**
|
||||
* 充值记录
|
||||
*/
|
||||
public Vo queryCouponRecharge(String vin, String account, String orderCode, String license, String phone, String qureyDate1, String queryDate2, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券获取
|
||||
*/
|
||||
public Vo getCoupon(String vin, String electronicAccounts, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费
|
||||
*/
|
||||
public boolean consume(CouponConsumeJlrPO couponConsumeJlr, List<CouponRechargeJlrPO> CouponRechargeJlrs);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.pojo.BaseUser;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface EnterpriseDao extends Dao {
|
||||
|
||||
/****
|
||||
* 获取经销商维护信息
|
||||
* @param name
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
public Vo searchEnterprise(String name,String abbrCode,
|
||||
Integer page, Integer rows);
|
||||
|
||||
/***
|
||||
* 删除经销商信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteById(String id);
|
||||
|
||||
/***
|
||||
* 保存经销商信息
|
||||
* @param enterprise
|
||||
* @return
|
||||
*/
|
||||
public boolean putEnterprise(EnterpriseJlr enterprise);
|
||||
|
||||
/****
|
||||
* 保存用户信息
|
||||
* @param systemUser
|
||||
* @return
|
||||
*/
|
||||
boolean putSystemUser(BaseUser systemUser);
|
||||
|
||||
/***
|
||||
* 根据id查询经销商
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public EnterpriseJlr getById(String id);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface OrderCheckDao extends Dao{
|
||||
|
||||
/**
|
||||
* 服务费用核对信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
public Vo list(HttpServletRequest request, int page, int raws, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state);
|
||||
|
||||
/**
|
||||
* 服务费用信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
public Vo lists(HttpServletRequest request, int page, int raws, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state,String state);
|
||||
|
||||
/***
|
||||
* 导出
|
||||
* @param request
|
||||
* @param code
|
||||
* @param orderCode
|
||||
* @param queryDate1
|
||||
* @param rescueCompanyName
|
||||
* @param queryDate2
|
||||
* @param check_state
|
||||
* @return
|
||||
*/
|
||||
JSONObject exportData(HttpServletRequest request, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state);
|
||||
|
||||
/***
|
||||
* 修改服务信息
|
||||
* @param uid
|
||||
* @param totalFee
|
||||
* @return
|
||||
*/
|
||||
boolean updateInfo(String uid,String totalFee);
|
||||
|
||||
}
|
||||
62
src/main/java/com/zhongdao/jlr/business/dao/RoleDao.java
Normal file
62
src/main/java/com/zhongdao/jlr/business/dao/RoleDao.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.JLRMenu;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import com.zhongdao.jlr.pojo.JLRAuthority;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface RoleDao extends Dao{
|
||||
|
||||
/***
|
||||
* 获取角色信息
|
||||
* @param request
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Vo getRoleInfo(HttpServletRequest request, String name);
|
||||
|
||||
/***
|
||||
* 获取树的信息
|
||||
* @return
|
||||
*/
|
||||
List<JLRMenu> getTreeInfo();
|
||||
|
||||
/***
|
||||
* 添加角色信息
|
||||
*/
|
||||
boolean updateRoleInfo(JLRRole jlrRole);
|
||||
|
||||
/***
|
||||
* 添加角色权限信息
|
||||
*/
|
||||
boolean updateRolesInfo(JLRAuthority jlrAuthority);
|
||||
|
||||
/***
|
||||
* 根据id获取角色信息
|
||||
* @return
|
||||
*/
|
||||
JLRRole getUser(String id);
|
||||
|
||||
/***
|
||||
* 根据角色id获取菜单信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getMenu(String id);
|
||||
|
||||
/***
|
||||
* 删除权限信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean deleteSupplier(Integer id);
|
||||
}
|
||||
104
src/main/java/com/zhongdao/jlr/business/dao/SupplierDao.java
Normal file
104
src/main/java/com/zhongdao/jlr/business/dao/SupplierDao.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.Contract;
|
||||
import com.zhongdao.jlr.business.vo.Destination;
|
||||
import com.zhongdao.jlr.business.vo.Enterprise;
|
||||
import com.zhongdao.jlr.pojo.JLRDestination;
|
||||
import com.zhongdao.jlr.pojo.JLRSupplier;
|
||||
import com.zhongdao.jlr.pojo.JLRUserContract;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface SupplierDao extends Dao{
|
||||
|
||||
/***
|
||||
* 获取合同信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getContractInfo(HttpServletRequest request,String name,String id);
|
||||
|
||||
/***
|
||||
* 获取指定的合同信息
|
||||
* @return
|
||||
*/
|
||||
List<Contract> getAssignContract(String id);
|
||||
|
||||
/***
|
||||
* 获取指定的目的地信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Destination> getAssignDestination(String id);
|
||||
|
||||
/***
|
||||
* 获取指定的供应商信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Enterprise> getAssignEnterprise(String id);
|
||||
|
||||
/***
|
||||
* 获取供应商信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getEnterpriseInfo(HttpServletRequest request,String name,String id);
|
||||
|
||||
|
||||
/***
|
||||
* 获取合同下的目的地信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getDestination(HttpServletRequest request,String name,String id);
|
||||
|
||||
/***
|
||||
* 为用户指定合同
|
||||
* @return
|
||||
*/
|
||||
boolean insertContractInfo(JLRUserContract jlrUserContract);
|
||||
|
||||
/***
|
||||
* 指定目的地
|
||||
* @return
|
||||
*/
|
||||
boolean insertDestinationInfo(JLRDestination jlrDestination);
|
||||
|
||||
/***
|
||||
* 指定供应商
|
||||
* @return
|
||||
*/
|
||||
boolean insertEnterpriseInfo(JLRSupplier jlrSupplier);
|
||||
|
||||
/***
|
||||
* 删除指定的合同
|
||||
* @return
|
||||
*/
|
||||
boolean deleteContractInfo(int cid,int id);
|
||||
|
||||
/***
|
||||
* 删除指定的供应商
|
||||
* @return
|
||||
*/
|
||||
boolean deleteEnterpriseInfo(int sid,int id);
|
||||
|
||||
/***
|
||||
* 删除指定的目的地
|
||||
* @return
|
||||
*/
|
||||
boolean deleteDestinationInfo(int did,int id);
|
||||
|
||||
/***
|
||||
*根据用户id获取合同信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<JLRUserContract> getContract(String id);
|
||||
}
|
||||
51
src/main/java/com/zhongdao/jlr/business/dao/UserInfoDao.java
Normal file
51
src/main/java/com/zhongdao/jlr/business/dao/UserInfoDao.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.zhongdao.jlr.business.dao;
|
||||
|
||||
import com.dubh.common.dao.Dao;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.pojo.BaseRole;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserInfoDao extends Dao {
|
||||
|
||||
/***
|
||||
* 获取角色信息
|
||||
* @return
|
||||
*/
|
||||
List<JLRRole> getRoleInfo();
|
||||
|
||||
/***
|
||||
* 获取经销商信息
|
||||
* @return
|
||||
*/
|
||||
List<EnterpriseJlr> getEnterpriseInfo();
|
||||
|
||||
/***
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
Vo getUserInfo(HttpServletRequest request, String name, String phone,String role,String username);
|
||||
|
||||
/***
|
||||
* 添加或更改用户信息
|
||||
*/
|
||||
boolean updateUserInfo(JLRUser user);
|
||||
|
||||
|
||||
/***
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
JLRUser getUser(String id);
|
||||
|
||||
/***
|
||||
* 根据编号删除用户
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
boolean deleteUser(JLRUser user);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.zhongdao.jlr.business.dao.BaseDao;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 登录
|
||||
*/
|
||||
@Repository("baseDaoImpl")
|
||||
public class BaseDaoImpl extends BaseDaoHibernate implements BaseDao {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getMenuInfo() {
|
||||
//获取登录信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
List<BaseMenu> lists=new ArrayList<>();
|
||||
List list=null;
|
||||
try {
|
||||
String sql = "select id, parent_id, name, action " +
|
||||
"from jlr_menu " +
|
||||
"where id in (" +
|
||||
"select menu_id from jlr_role_authority " +
|
||||
"where role_id ="+logininfo.getRole_id()+")";
|
||||
//获取菜单信息
|
||||
list = getRsBySql(sql);
|
||||
//遍历菜单信息
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
BaseMenu baseMenu = new BaseMenu();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
baseMenu.setId(Integer.valueOf(objects[0].toString()));
|
||||
baseMenu.setParent_id(Integer.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
baseMenu.setName(objects[2] == null ? "" : objects[2].toString());
|
||||
baseMenu.setAction(objects[3] == null ? "" : objects[3].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(baseMenu);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getParentMenuInfo() {
|
||||
//获取登录信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
//将角色编号存入集合中
|
||||
List<BaseMenu> lists=new ArrayList<>();
|
||||
List list=null;
|
||||
try {
|
||||
String sql = "select b.id,b.parent_id,b.name,b.action " +
|
||||
"from (select parent_id " +
|
||||
"from (select r.id," +
|
||||
"r.role_id,r.menu_id,p.parent_id parent_id,p.id n,p.name,p.action" +
|
||||
" from jlr_role_authority r " +
|
||||
"inner join jlr_menu p on" +
|
||||
" r.menu_id=p.id " +
|
||||
"where role_id="+logininfo.getRole_id()+") m " +
|
||||
"group by " +
|
||||
"m.parent_id) m " +
|
||||
"inner join jlr_menu b on m.parent_id=b.id";
|
||||
//获取父级菜单信息
|
||||
list = getRsBySql(sql);
|
||||
//遍历菜单信息
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
BaseMenu baseMenu = new BaseMenu();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
baseMenu.setId(Integer.valueOf(objects[0].toString()));
|
||||
baseMenu.setParent_id(Integer.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
baseMenu.setName(objects[2] == null ? "" : objects[2].toString());
|
||||
baseMenu.setAction(objects[3] == null ? "" : objects[3].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(baseMenu);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.CaseDao;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.JLRepqr;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Repository("caseDaoImpl")
|
||||
public class CaseDaoImpl extends BaseDaoHibernate implements CaseDao {
|
||||
|
||||
private final static SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
|
||||
|
||||
@Override
|
||||
public Vo casesListService(String state,HttpServletRequest request, String caseCode, String frame_code, String rescueState, String createTime, String finishTime, String companyName,String plateNumber) {
|
||||
//获取登录信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=null;
|
||||
//如果state为0则证明此操作为管理员,否则是经销商
|
||||
if("0".equals(state)){
|
||||
if("1".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"and u.order_status not in (51,53,55) " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+")");
|
||||
}else if("2".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+") " +
|
||||
"and u.order_status = 55");
|
||||
}else if("3".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+") " +
|
||||
"and u.order_status = 51");
|
||||
}else {
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,u.task_status task_status,u.plate_number plate_number from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.id,u.order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.id id,u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,t.task_status task_status,u.plate_number plate_number from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"left join jlr_supplier_visual v on v.supplier_id=s.id " +
|
||||
"where " +
|
||||
"u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id =" + logininfo.getId() + ") ");
|
||||
}
|
||||
}else if("1".equals(state)){
|
||||
if("1".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"left join jlr_supplier_visual v on v.supplier_id=s.id " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+") " +
|
||||
"and u.order_status not in (51,53,55)");
|
||||
// "and u.order_status = 31 " +
|
||||
// "and v.jlr_user_id =" + logininfo.getId());
|
||||
}else if("2".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"left join jlr_supplier_visual v on v.supplier_id=s.id " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+") ");
|
||||
// "and u.order_status = 55 " +
|
||||
// "and v.jlr_user_id =" + logininfo.getId());
|
||||
}else if("3".equals(rescueState)){
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time create_time," +
|
||||
"u.vin_no vin_no,s.name name," +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"left join supplier s on t.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"left join jlr_supplier_visual v on v.supplier_id=s.id " +
|
||||
"where u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+") ");
|
||||
// "and u.order_status = 51 " +
|
||||
// "and v.jlr_user_id =" + logininfo.getId());
|
||||
}else {
|
||||
sql = new StringBuffer("select DISTINCT u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.order_status order_status,u.task_status task_status,u.plate_number plate_number from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.id,u.order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,t.task_status task_status,u.plate_number plate_number from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.id id,u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,t.task_status task_status,u.plate_number plate_number from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id=s.id " +
|
||||
"left join base_service b on b.id=u.service_id " +
|
||||
"left join jlr_supplier_visual v on v.supplier_id=s.id " +
|
||||
"where " +
|
||||
"u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id =" + logininfo.getId() + ")") ;
|
||||
// "and u.order_status in (31,53,51,55) " +
|
||||
// "and v.jlr_user_id =" + logininfo.getId());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(frame_code)) {
|
||||
sql.append(" and u.vin_no like '%" + frame_code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(caseCode)) {
|
||||
sql.append(" and u.code like '%" + caseCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(companyName)) {
|
||||
sql.append(" and s.name like '%" + companyName + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(plateNumber)) {
|
||||
sql.append(" and u.plate_number like '%" + plateNumber + "%'");
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(createTime)) {
|
||||
sql.append(" and u.create_time >= '"+createTime+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(finishTime)) {
|
||||
sql.append(" and u.create_time <= '"+finishTime+"'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取救援信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取救援信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ORDER_CODE","CREATE_TIME","VIN_NO","NAME","CODE","SERVICE_NAME","STATUS","TASK_STATUS","PLATE_NUMBER"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo caseEnterQuery(String state,HttpServletRequest request, String caseCode, String frame_code, String createTime, String finishTime) {
|
||||
//获取登录信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=null;
|
||||
if("0".equals(state)){
|
||||
sql = new StringBuffer("select DISTINCT u.tid tid,u.id id,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, "+
|
||||
"s.code code,b.name serviceName,u.order_status order_status,w.state state,w.update_time update_time from "+
|
||||
"(select t.create_time createTime,t.code taskCode,u.code code,u.create_time,u.vin_no,u.id id,u.order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,t.id tid from user_order_his u "+
|
||||
"left join task_order_his t on t.user_order_id=u.id "+
|
||||
"union select t.create_time createTime,t.code taskCode,u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.id id,u.order_status order_status,u.service_id service_id "+
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,t.id tid from user_order u "+
|
||||
"left join task_order t on t.user_order_id=u.id "+
|
||||
") u "+
|
||||
"left join supplier s on u.service_supplier_id=s.id "+
|
||||
"left join base_service b on b.id=u.service_id "+
|
||||
"left join jlr_epqr w on w.task_order_id = u.tid " +
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) " +
|
||||
"and u.order_status in (21,23,25,28,31) " +
|
||||
"and w.state = 1 " +
|
||||
"and u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id ="+logininfo.getId()+")");
|
||||
}else{
|
||||
sql = new StringBuffer("select DISTINCT u.tid tid,u.id id,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, "+
|
||||
"s.code code,b.name serviceName,u.order_status order_status,w.state state,w.update_time update_time from "+
|
||||
"(select t.create_time createTime,t.code taskCode,u.code code,u.create_time,u.vin_no,u.id id,u.order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code,t.id tid from user_order_his u "+
|
||||
"left join task_order_his t on t.user_order_id=u.id "+
|
||||
"union select t.create_time createTime,t.code taskCode,u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.id id,u.order_status order_status,u.service_id service_id "+
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code,t.id tid from user_order u "+
|
||||
"left join task_order t on t.user_order_id=u.id "+
|
||||
") u "+
|
||||
"left join supplier s on u.service_supplier_id=s.id "+
|
||||
"left join jlr_epqr w on w.task_order_id = u.tid " +
|
||||
"left join base_service b on b.id=u.service_id "+
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) " +
|
||||
"and u.order_status in (21,23,25,28,31) " +
|
||||
"and u.destination_code in (select contract_destination_id from jlr_destination_visual where jlr_user_id ="+logininfo.getId()+")");
|
||||
}
|
||||
if (StringUtils.isNotBlank(frame_code)) {
|
||||
sql.append(" and u.vin_no like '%" + frame_code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(caseCode)) {
|
||||
sql.append(" and u.code like '%" + caseCode + "%'");
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(createTime)) {
|
||||
sql.append(" and u.create_time >= '"+createTime+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(finishTime)) {
|
||||
sql.append(" and u.create_time <= '"+finishTime+"'");
|
||||
}
|
||||
String countSql=sql.append(" order by w.update_time desc").toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取进店救援信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取进店救援信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"TID","ID","ORDER_CODE","CREATE_TIME","VIN_NO","NAME","CODE","SERVICE_NAME","STATUS","STATE"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo caseEnterInfo(HttpServletRequest request, String caseCode,String tid) {
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
//声明一个vo对象
|
||||
Vo vo=new Vo();
|
||||
//创建sql
|
||||
StringBuffer sql=new StringBuffer("select DISTINCT u.id uid,u.tid tid,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, "+
|
||||
"s.code code,b.name serviceName,u.model model,u.plate_number plate_number,m.start_time start_time,j.level_name levelName," +
|
||||
"u.finish_time finish_time,j.level_name levelNames,d.name dName,d.brand_name brandName,e.dms_code dms_code," +
|
||||
"e.trouble_reason trouble_reason,e.mileage mileage,e.dphm dphm,e.arrive_time arrive_time,e.remaer remaer," +
|
||||
"e.choice_type choice_type,e.trouble_code trouble_code,e.repair repair,e.ref_time ref_time,e.finish_time finishes_time" +
|
||||
",e.hand_time hand_time,e.use_time use_time,e.state state from "+
|
||||
"(select u.code code,u.create_time,u.vin_no,u.order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order_his u "+
|
||||
"left join task_order_his t on t.user_order_id=u.id "+
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.order_status order_status,u.service_id service_id "+
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order u "+
|
||||
"left join task_order t on t.user_order_id=u.id "+
|
||||
") u "+
|
||||
"left join supplier s on u.service_supplier_id = s.id "+
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_member_service_group m on u.member_service_group_id=m.id " +
|
||||
"left join contract_trouble_level j on j.id = u.malfunction_level1 " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"left join jlr_epqr e on e.task_order_id = u.tid " +
|
||||
"where u.id = '" + caseCode+"'");
|
||||
if (StringUtils.isNotBlank(tid)) {
|
||||
sql.append(" and u.tid = '" + tid +"'");
|
||||
}
|
||||
try {
|
||||
//获取案件详情信息
|
||||
List list = getRsBySql(sql.toString());
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"UID","TID","ORDER_CODE", "CREATE_TIME", "VIN_NO", "NAME", "CODE", "SERVICE_NAME", "MODEL", "PLATENUMBER", "STARTTIME", "LEVELNAME1", "FINISHTIME", "LEVELNAME2", "DNAME", "BRANDNAME", "DMS", "REASON", "MILEAGE", "DNUMBER", "ARRIVETIME", "REMARK", "CHOICE", "PART", "REPAIR", "REFTIME", "FINTIME", "HANDTIME", "USETIME","STATE"}));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getTroubleCode(HttpServletRequest request) throws Exception {
|
||||
//获取参数
|
||||
String firstParam = request.getParameter("firstParam");
|
||||
String flag = request.getParameter("flag");
|
||||
//声明一个对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//创建集合
|
||||
List<String> idList = new ArrayList<String>();
|
||||
List<String> listfirst = new ArrayList<String>();// 祖
|
||||
List<String> listSecond = new ArrayList<String>();// 父
|
||||
|
||||
// 第一级系统
|
||||
if ("1".equals(flag)) {
|
||||
String sql = "select id,name from jlr_trouble_parts where parent_id = 0";
|
||||
//获取一级故障信息
|
||||
List list = getRsBySql(sql);
|
||||
//遍历获取到的信息将其放入对象中并将对象放入集合中
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
listfirst.add(objects[1].toString());
|
||||
idList.add(objects[0].toString());
|
||||
}
|
||||
jsonObject.put("listfirst", listfirst);
|
||||
jsonObject.put("idList", idList);
|
||||
}
|
||||
}
|
||||
// 第二级系统和第三级
|
||||
if ("2".equals(flag) || "3".equals(flag)) {
|
||||
String sql = "select id,name from jlr_trouble_parts where parent_id ="+firstParam;
|
||||
//获取二级故障和三级故障信息将其放入对象中并将对象放入集合中
|
||||
List list = getRsBySql(sql);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
listSecond.add(objects[1].toString());
|
||||
idList.add(objects[0].toString());
|
||||
}
|
||||
jsonObject.put("listSecond", listSecond);
|
||||
jsonObject.put("idList", idList);
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject caseDetailSave(HttpServletRequest request) throws Exception {
|
||||
//声明一个object对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//获取参数
|
||||
String uid = request.getParameter("uid");
|
||||
String tid = request.getParameter("tid");
|
||||
String mileage = request.getParameter("mileage");
|
||||
String dphm = request.getParameter("dphm");
|
||||
Date arriveTime = TextUtils.isBlank(request.getParameter("arriveTime")) ? null : df.parse(request.getParameter
|
||||
("arriveTime"));
|
||||
Date refTime = TextUtils.isBlank(request.getParameter("refTime")) ? null : df.parse(request.getParameter
|
||||
("refTime"));
|
||||
Date repairFinishTime = TextUtils.isBlank(request.getParameter("repairFinishTime")) ? null : df.parse(request
|
||||
.getParameter("repairFinishTime"));
|
||||
Date handTime = TextUtils.isBlank(request.getParameter("handTime")) ? null : df.parse(request.getParameter
|
||||
("handTime"));
|
||||
String finalChoice = request.getParameter("finalChoice");
|
||||
Date useTime = TextUtils.isBlank(request.getParameter("useTime")) ? null : df.parse(request.getParameter
|
||||
("useTime"));
|
||||
String troubleCodeValue = request.getParameter("troubleCodeValue");
|
||||
String troubleReasonVaule = request.getParameter("troubleReasonValue");
|
||||
String repair = request.getParameter("repair");
|
||||
String remark = request.getParameter("remark");
|
||||
String dmsCode = request.getParameter("dmsCode");
|
||||
String state = request.getParameter("state");
|
||||
JLRepqr epqrJlr = null;
|
||||
//创建一个时间对象
|
||||
Date date=new Date();
|
||||
try {
|
||||
//创建一个sql
|
||||
StringBuffer hql =new StringBuffer("from JLRepqr where order_id= " + uid);
|
||||
if(tid != null && tid != ""){
|
||||
hql.append(" and task_order_id ="+tid);
|
||||
}
|
||||
//根据订单id获取案件详情信息
|
||||
List list = getRsByHql(hql.toString());
|
||||
if (list != null && list.size() > 0) {
|
||||
epqrJlr = (JLRepqr) list.get(0);
|
||||
} else {
|
||||
//若信息为空则证明该操作为添加
|
||||
epqrJlr = new JLRepqr();
|
||||
//生成主键id并放入对象中
|
||||
epqrJlr.setId(Integer.valueOf((System.currentTimeMillis() + "").substring(4)));
|
||||
epqrJlr.setCreate_time(date);
|
||||
}
|
||||
if(!TextUtils.isBlank(tid)){
|
||||
epqrJlr.setTask_order_id(Integer.valueOf(tid));
|
||||
}else {
|
||||
epqrJlr.setTask_order_id(0);
|
||||
}
|
||||
epqrJlr.setUpdate_time(date);
|
||||
epqrJlr.setHand_time(handTime);
|
||||
epqrJlr.setState(Integer.valueOf(state));
|
||||
epqrJlr.setMileage(TextUtils.isBlank(mileage) ? 0 : Integer.valueOf(mileage));
|
||||
epqrJlr.setDphm(dphm);
|
||||
epqrJlr.setArrive_time(arriveTime);
|
||||
epqrJlr.setRef_time(refTime);
|
||||
epqrJlr.setFinish_time(repairFinishTime);
|
||||
epqrJlr.setChoice_type(finalChoice);
|
||||
epqrJlr.setUse_time(useTime);
|
||||
epqrJlr.setTrouble_reason(troubleReasonVaule);
|
||||
epqrJlr.setTrouble_code(troubleCodeValue);
|
||||
epqrJlr.setRepair(repair);
|
||||
epqrJlr.setRemaer(remark);
|
||||
epqrJlr.setOrder_id(Integer.valueOf(uid));
|
||||
epqrJlr.setDms_code(dmsCode);
|
||||
saveOrUpdate(epqrJlr);
|
||||
jsonObject.put("sign", true);
|
||||
//回传json对象
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
jsonObject.put("sign", false);
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.CouponDao;
|
||||
import com.zhongdao.jlr.business.vo.CouponConsumeJlr;
|
||||
import com.zhongdao.jlr.business.vo.CouponJlrVO;
|
||||
import com.zhongdao.jlr.business.vo.CouponRechargeJlr;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.CouponConsumeJlrPO;
|
||||
import com.zhongdao.jlr.pojo.CouponRechargeJlrPO;
|
||||
import com.zhongdao.jlr.util.MTextUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository("couponDaoImpl")
|
||||
public class CouponDaoImpl extends BaseDaoHibernate implements CouponDao {
|
||||
|
||||
@Override
|
||||
public Vo searchConsume(String vin, String electronicAccounts,String userPhone, int page, int raws) {
|
||||
//声明一个vo对象用来存储账户信息和账户数据总数
|
||||
Vo vo = new Vo();
|
||||
//声明一个分页类用来存储页数和每页多少条数据
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
try {
|
||||
//sql动态拼接
|
||||
StringBuffer sql = new StringBuffer("select cj.electronic_accounts, cj.vin_code,cj.user_name,cj.user_phone,cj.license,cj.remark,ifNull((select sum((ifNull((recharge_count),0)-ifNull((consume_count),0))) as result from jlr_coupon_recharge j where j.overdue_time>NOW() and j.vin_code=cj.vin_code),0) as result ,cj.e_password from jlr_coupon cj where 1=1");
|
||||
if (!TextUtils.isEmpty(vin) || !TextUtils.isEmpty(electronicAccounts) || !TextUtils.isEmpty(userPhone)) {
|
||||
if (!TextUtils.isEmpty(vin)) {
|
||||
sql.append(" and cj.vin_code like '%" + vin + "%'");
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(electronicAccounts)) {
|
||||
sql.append(" and cj.electronic_accounts like '%" + electronicAccounts + "%'");
|
||||
}
|
||||
if (!TextUtils.isEmpty(userPhone)) {
|
||||
sql.append(" and cj.USER_PHONE like '%" + userPhone + "%'");
|
||||
}
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String sqlStr =sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
List<Object[]> list = getRsBySql(sqlStr);
|
||||
//声明一个list集合用来存储账户信息对象
|
||||
List<CouponJlrVO> resultList = new ArrayList<>();
|
||||
//遍历账户信息数据,并将每一个对象放入集合中
|
||||
for (Object[] obj : list) {
|
||||
CouponJlrVO couponvo = new CouponJlrVO();
|
||||
couponvo.setElectronicAccounts(MTextUtils.objectToString(obj[0]));
|
||||
couponvo.setVinCode(MTextUtils.objectToString(obj[1]));
|
||||
couponvo.setUserName(MTextUtils.objectToString(obj[2]));
|
||||
couponvo.setUserPhone(MTextUtils.objectToString(obj[3]));
|
||||
couponvo.setLicense(MTextUtils.objectToString(obj[4]));
|
||||
couponvo.setRemark(MTextUtils.objectToString(obj[5]));
|
||||
couponvo.setCharge(MTextUtils.stringToDouble(MTextUtils.objectToString(obj[6])));
|
||||
couponvo.setPassword(MTextUtils.objectToString(obj[7]));
|
||||
resultList.add(couponvo);
|
||||
}
|
||||
vo.setRows(resultList);
|
||||
//获取账户数据总数
|
||||
int size = getRsCountsBySelectSql(countSql);
|
||||
vo.setTotal(size);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCouponConsume(String vin, int page, int raws) {
|
||||
//声明一个分页类用来存储页数和每页多少条数据
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
//声明一个list集合用来存储用户代金券消费记录
|
||||
List<CouponConsumeJlr> lists=new ArrayList<>();
|
||||
//时间格式化转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Vo vo = new Vo();
|
||||
try {
|
||||
//获取用户代金券消费记录
|
||||
List list = getRsBySql("select vin_code,consume_count,consume_time,settlement_state,remark from jlr_coupon_consume where VIN_CODE='" + vin + "' order by consume_time desc limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows());
|
||||
//遍历用户代金券消费记录并将其放入list集合中
|
||||
if(list != null && list.size()>0){
|
||||
for (int i=0;i<list.size();i++){
|
||||
Object[] objects= (Object[]) list.get(i);
|
||||
CouponConsumeJlr couponConsumeJlr=new CouponConsumeJlr();
|
||||
couponConsumeJlr.setVinCode(objects[0] == null ? "" : objects[0].toString());
|
||||
couponConsumeJlr.setConsumeCount(Double.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
couponConsumeJlr.setConsumeTime(simpleDateFormat.parse(objects[2].toString()));
|
||||
couponConsumeJlr.setSettlementState(Integer.valueOf(objects[3] == null ? "0" : objects[3].toString()));
|
||||
couponConsumeJlr.setRemark(objects[4] == null ? "" : objects[4].toString());
|
||||
lists.add(couponConsumeJlr);
|
||||
}
|
||||
}
|
||||
vo.setRows(lists);
|
||||
//获取用户代金券消费记录总条数
|
||||
vo.setTotal(getRsCountsBySelectSql("select vin_code,consume_count,consume_time,settlement_state,remark from jlr_coupon_consume where VIN_CODE='" + vin + "' order by consume_time desc"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCouponRecharge(String vin, int page, int raws) {
|
||||
Vo vo = new Vo();
|
||||
//声明一个分页类用来存储页数和每页多少条数据
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//时间格式化转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
//声明一个集合用来存储用户的代金券充值记录
|
||||
List<CouponRechargeJlr> lists=new ArrayList<>();
|
||||
try {
|
||||
//获取用户的代金券充值记录
|
||||
List list = getRsBySql("select task_order_id,recharge_count,service_name,overdue_time,recharge_time from jlr_coupon_recharge where VIN_CODE='" + vin + "' limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows());
|
||||
//遍历充值信息及其放入集合中
|
||||
if(list != null && list.size()>0){
|
||||
for (int i=0;i<list.size();i++){
|
||||
Object[] objects= (Object[]) list.get(i);
|
||||
CouponRechargeJlr couponRechargeJlr=new CouponRechargeJlr();
|
||||
couponRechargeJlr.setOrderCode(objects[0] == null ? "" : objects[0].toString());
|
||||
couponRechargeJlr.setRechargeCount(Double.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
couponRechargeJlr.setServiceName(objects[2] == null ? "" : objects[2].toString());
|
||||
couponRechargeJlr.setOverdueTime(simpleDateFormat.parse(objects[3].toString()));
|
||||
couponRechargeJlr.setRechargeTime(simpleDateFormat.parse(objects[4].toString()));
|
||||
lists.add(couponRechargeJlr);
|
||||
}
|
||||
}
|
||||
vo.setRows(lists);
|
||||
//获取用户充值记录总条数
|
||||
vo.setTotal(getRsCountsBySelectSql("select order_id,recharge_count,service_name,overdue_time,recharge_time from jlr_coupon_recharge where VIN_CODE='" + vin + "'"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo queryCouponConsume(String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String queryDate1, String queryDate2, int page, int raws) {
|
||||
//声明一个分页类用来存储页数和每页多少条数据
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
Vo vo = new Vo();
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT c.id,c.vin_code,c.consume_count,c.electronic_accounts,r.user_phone,r.license,e.NAME,c.settlement_state,c.CONSUME_TIME,c.reparie_info,c.hitch_info,c.settle_time,c.create_time,c.remark\n" +
|
||||
"FROM jlr_coupon_consume c LEFT JOIN jlr_coupon r ON c.VIN_CODE = r.VIN_CODE\n" +
|
||||
"LEFT JOIN jlr_enterprise e on c.enterprise_id = e.ID\n where 1=1 ");
|
||||
if (StringUtils.isNotBlank(vin)) {
|
||||
sql.append(" and c.VIN_CODE like '%" + vin + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(account)) {
|
||||
sql.append(" and c.electronic_accounts like '%" + account + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(RecuseCompanyName)) {
|
||||
sql.append(" and e.NAME like '%" + RecuseCompanyName + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
sql.append(" and r.USER_PHONE like '%" + phone + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(license)) {
|
||||
sql.append(" and r.LICENSE like '%" + license + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(state)) {
|
||||
sql.append(" and c.settlement_state = '" + state + "'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(rescueCompanyCode)) {
|
||||
sql.append(" and c.enterprise_id = '" + rescueCompanyCode + "'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and c.CONSUME_TIME >= '"+queryDate1+"'");
|
||||
}
|
||||
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and c.CONSUME_TIME <= '"+queryDate2+"'");
|
||||
}
|
||||
String countSql=sql.append("ORDER BY CONSUME_TIME DESC ").toString();
|
||||
String info=sql.append("limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID", "VIN_CODE","CONSUME_COUNT","ELECTRONIC_ACCOUNTS","USER_PHONE","LICENSE","NAME","SETTLEMENT_STATE","CONSUME_TIME","REPARIE_INFO","HITCH_INFO","SETTLE_TIME","CREATE_TIME","REMARK"}));
|
||||
}
|
||||
vo.setTotal(getRsCountsBySelectSql(countSql));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateConsumeState(List<CouponRechargeJlrPO> couponechargeList, String cId, String state) {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
session = getSessionFactory().getCurrentSession().getSessionFactory().openSession();
|
||||
tx = session.beginTransaction();
|
||||
//sql动态拼接
|
||||
StringBuffer sql = new StringBuffer("update jlr_coupon_consume set SETTLEMENT_STATE = " + state);
|
||||
if (StringUtils.isBlank(state)) {
|
||||
return false;
|
||||
}
|
||||
if ("10".equals(state)) {
|
||||
sql.append(", settle_time = NOW()");
|
||||
}
|
||||
if (StringUtils.isBlank(cId)) {
|
||||
return false;
|
||||
} else {
|
||||
sql.append(" where id in (" + cId + ")");
|
||||
}
|
||||
//更改状态
|
||||
SQLQuery query = session.createSQLQuery(sql.toString());
|
||||
query.executeUpdate();
|
||||
|
||||
//回滚充值记录
|
||||
for (CouponRechargeJlrPO c : couponechargeList) {
|
||||
session.saveOrUpdate(c);
|
||||
}
|
||||
//事务提交
|
||||
tx.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
//事务回滚
|
||||
tx.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
closeResouce(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public Vo queryCouponRecharge(String vin, String account, String orderCode, String license, String phone, String queryDate1, String queryDate2, int page, int raws) {
|
||||
Vo vo = new Vo();
|
||||
//声明一个分页类用来存储页数和每页多少条数据
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
//sql动态拼接
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT c.ID,c.VIN_CODE,u.code,c.RECHARGE_TIME,c.RECHARGE_COUNT,c.SEATE_NAME,c.REMARK,c.SERVICE_NAME,c.OVERDUE_TIME,c.CONSUME_COUNT,r.ELECTRONIC_ACCOUNTS,c.CREATE_TIME, " +
|
||||
"r.LICENSE, r.USER_PHONE\n" +
|
||||
"FROM jlr_coupon_recharge c LEFT JOIN jlr_coupon r ON c.VIN_CODE = r.VIN_CODE " +
|
||||
"LEFT JOIN (SELECT ID,CODE FROM user_order union SELECT ID,CODE FROM user_order_his) u on u.id = c.order_id " +
|
||||
"where 1=1 ");
|
||||
if (StringUtils.isNotBlank(vin)) {
|
||||
sql.append(" and c.VIN_CODE like '%" + vin + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(account)) {
|
||||
sql.append(" and r.ELECTRONIC_ACCOUNTS like '%" + account + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
sql.append(" and c.task_order_id like '%" + orderCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
sql.append(" and r.USER_PHONE like '%" + phone + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(license)) {
|
||||
sql.append(" and r.LICENSE like '%" + license + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and c.RECHARGE_TIME >= '"+queryDate1+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and c.RECHARGE_TIME <= '"+queryDate2+"'");
|
||||
}
|
||||
String countSql=sql.append(" ORDER BY c.CREATE_TIME DESC").toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取充值记录
|
||||
List list = getRsBySql(info);
|
||||
//获取充值记录总数
|
||||
List lists = getRsBySql(countSql);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID", "VIN_CODE", "ORDER_CODE", "RECHARGE_TIME", "RECHARGE_COUNT", "SEATE_NAME", "REMARK", "SERVICE_NAME", "OVERDUE_TIME", "CONSUME_COUNT", "ELECTRONIC_ACCOUNTS", "CREATE_TIME", "LICENSE", "USER_PHONE"}));
|
||||
}
|
||||
//获取充值记录总条数
|
||||
vo.setTotal(lists.size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCoupon(String vin, String electronicAccounts, int page, int raws) {
|
||||
Vo vo = new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
try {
|
||||
// select cj.electronic_accounts, cj.vin_code,cj.user_name,cj.user_phone,cj.license,cj.remark,
|
||||
// nvl((select sum((nvl((recharge_count),0)-nvl((consume_count),0))) as result from coupon_recharge_jlr j where j.overdue_time<SYSDATE and j.vin_code=cj.vin_code),0) as result
|
||||
// from Coupon_Jlr cj
|
||||
StringBuffer sql = new StringBuffer("select cj.electronic_accounts, cj.vin_code,cj.user_name,cj.user_phone,cj.license,cj.remark,ifNull((select sum((ifNull((recharge_count),0)-ifNull((consume_count),0))) as result from jlr_coupon_recharge j where j.overdue_time>NOW() and j.vin_code=cj.vin_code),0) as result,cj.e_password from jlr_coupon cj where 1=1");
|
||||
if (!TextUtils.isEmpty(vin) || !TextUtils.isEmpty(electronicAccounts)) {
|
||||
if (!TextUtils.isEmpty(vin)) {
|
||||
sql.append(" and cj.vin_code='" + vin + "'");
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(electronicAccounts)) {
|
||||
sql.append(" and cj.electronic_accounts='" + electronicAccounts + "'");
|
||||
}
|
||||
}
|
||||
String count=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
List<Object[]> list = getRsBySql(info);
|
||||
List<CouponJlrVO> resultList = new ArrayList<>();
|
||||
for (Object[] obj : list) {
|
||||
CouponJlrVO couponvo = new CouponJlrVO();
|
||||
couponvo.setElectronicAccounts(MTextUtils.objectToString(obj[0]));
|
||||
couponvo.setVinCode(MTextUtils.objectToString(obj[1]));
|
||||
couponvo.setUserName(MTextUtils.objectToString(obj[2]));
|
||||
couponvo.setUserPhone(MTextUtils.objectToString(obj[3]));
|
||||
couponvo.setLicense(MTextUtils.objectToString(obj[4]));
|
||||
couponvo.setRemark(MTextUtils.objectToString(obj[5]));
|
||||
couponvo.setCharge(MTextUtils.stringToDouble(MTextUtils.objectToString(obj[6])));
|
||||
couponvo.setPassword(MTextUtils.objectToString(obj[7]));
|
||||
resultList.add(couponvo);
|
||||
}
|
||||
vo.setRows(resultList);
|
||||
List lists = getRsBySql(count);
|
||||
int size=lists.size();
|
||||
vo.setTotal(size);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean consume(CouponConsumeJlrPO couponConsumeJlr, List<CouponRechargeJlrPO> couponRechargeJlrs) {
|
||||
Session session = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
//获取session
|
||||
session = getSessionFactory().getCurrentSession().getSessionFactory().openSession();
|
||||
//开启事务
|
||||
tx = session.beginTransaction();
|
||||
//保存或修改
|
||||
session.saveOrUpdate(couponConsumeJlr);
|
||||
//批量保存或修改
|
||||
for (CouponRechargeJlrPO c : couponRechargeJlrs) {
|
||||
session.saveOrUpdate(c);
|
||||
}
|
||||
//提交事务
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
//事务回滚
|
||||
tx.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
closeResouce(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.EnterpriseDao;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.BaseUser;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 经销商维护
|
||||
*/
|
||||
|
||||
@Repository(value = "enterpriseDaoImpl")
|
||||
public class EnterpriseDaoImpl extends BaseDaoHibernate implements EnterpriseDao {
|
||||
|
||||
@Override
|
||||
public Vo searchEnterprise(String name,String abbrCode, Integer page, Integer rows) {
|
||||
Vo vo=new Vo();
|
||||
//声明一个List集合用于接收查询的数据
|
||||
List list=null;
|
||||
//声明一个分页的实体类分页数据放入实体类中
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(rows);
|
||||
//声明一个字符串对象并将所需要的sql语句拼接到字符串中
|
||||
StringBuffer hqlSb=new StringBuffer("select name,abbr_code,address,contact,id from jlr_enterprise where 1=1");
|
||||
if(!TextUtils.isEmpty(name)){
|
||||
hqlSb.append(" and name like '%"+name+"%'");
|
||||
}
|
||||
if(!TextUtils.isEmpty(abbrCode)){
|
||||
hqlSb.append(" and abbr_code like '%"+abbrCode+"%'");
|
||||
}
|
||||
//声明一个字符串用于查询经销商数据总数
|
||||
String sql=hqlSb.toString();
|
||||
String hql=hqlSb.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
//声明一个List集合用于存放Enterprise对象
|
||||
List<EnterpriseJlr> lists=new ArrayList<>();
|
||||
try {
|
||||
list=getRsBySql(hql);
|
||||
if(list != null && list.size()>0){
|
||||
//遍历查询到数据并将其放入Enterprise对象中
|
||||
for (int i=0;i<list.size();i++){
|
||||
Object[] objects= (Object[]) list.get(i);
|
||||
EnterpriseJlr enterpriseJlr=new EnterpriseJlr();
|
||||
enterpriseJlr.setName(objects[0] == null ? "" : objects[0].toString());
|
||||
enterpriseJlr.setAbbr_code(objects[1] == null ? "" : objects[1].toString());
|
||||
enterpriseJlr.setAddress(objects[2] == null ? "" : objects[2].toString());
|
||||
enterpriseJlr.setContact(objects[3] == null ? "" : objects[3].toString());
|
||||
enterpriseJlr.setId(Integer.valueOf(objects[4].toString()));
|
||||
//将Enterprise对象放入集合中
|
||||
lists.add(enterpriseJlr);
|
||||
}
|
||||
}
|
||||
vo.setRows(lists);
|
||||
//获取查询经销商信息的总数
|
||||
int size=getRsCountsBySelectSql(sql);
|
||||
vo.setTotal(size);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
try {
|
||||
deleteHql("delete EnterpriseJlr where id="+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putEnterprise(EnterpriseJlr enterprise) {
|
||||
try {
|
||||
saveOrUpdate(enterprise);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putSystemUser(BaseUser systemUser) {
|
||||
try {
|
||||
updateSql("update jlr_user set password = '"+systemUser.getPassword() +"' where id="+systemUser.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterpriseJlr getById(String id) {
|
||||
EnterpriseJlr enterprisejlr=null;
|
||||
try {
|
||||
enterprisejlr=(EnterpriseJlr) getObjectHql("from EnterpriseJlr where id ="+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return enterprisejlr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.OrderCheckDao;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.business.vo.OrderCheckExcelVO;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.business.vo.UserOrderExcelVO;
|
||||
import com.zhongdao.jlr.util.MTextUtils;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class OrderCheckDaoImpl extends BaseDaoHibernate implements OrderCheckDao{
|
||||
|
||||
@Override
|
||||
public Vo list(HttpServletRequest request, int page, int raws, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state) {
|
||||
//创建一个vo对象
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
//创建sql
|
||||
StringBuffer sql=new StringBuffer("select u.id id,u.code code,u.vin_no vin_no,s.name name,u.vehicle_point_address vehicle_point_address," +
|
||||
"b.name serviceName,u.create_time,u.order_status,c.other_amount other_amount,c.account_status account_status," +
|
||||
"c.settle_mileage_bc settle_mileage_bc,d.address address from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id " +
|
||||
"left join supplier s on s.id = t.service_supplier_id " +
|
||||
"left join jlr_supplier_visual j on j.supplier_id = s.id " +
|
||||
"left join task_order_cost_his c on c.user_order_id = u.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"where c.account_status in (2,3) and j.jlr_user_id = "+logininfo.getId());
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
sql.append(" and u.code like '%" + orderCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(rescueCompanyName)) {
|
||||
sql.append(" and s.name like '%" + rescueCompanyName + "%'");
|
||||
}
|
||||
if ("8".equals(check_state)){
|
||||
sql.append(" and (c.account_status = 2 or c.account_status = 3)");
|
||||
}else if(StringUtils.isNotBlank(check_state)){
|
||||
sql.append(" and c.account_status = "+check_state);
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and u.create_time >= '"+queryDate1+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and u.create_time <= '"+queryDate2+"'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取服务费用核对信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取服务费用核对信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","ORDER_CODE","VIN_NO","NAME","ADDRESS","SERVICE_NAME","CREATE_TIME","RECUESTATE","MONEY","ACCOUNTSTATE","MILE","DESTINATION"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo lists(HttpServletRequest request, int page, int raws, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state,String state) {
|
||||
//创建一个vo对象
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(page);
|
||||
pageInfo.setRows(raws);
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
//创建sql
|
||||
StringBuffer sql=null;
|
||||
System.out.println(state);
|
||||
if("0".equals(state)){
|
||||
sql=new StringBuffer("select u.id id,u.code code,u.vin_no vin_no,s.name name,u.vehicle_point_address vehicle_point_address," +
|
||||
"b.name serviceName,u.create_time,u.order_status,c.other_amount other_amount,c.account_status account_status," +
|
||||
"c.settle_mileage_bc settle_mileage_bc,d.address address from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id " +
|
||||
"left join supplier s on s.id = t.service_supplier_id " +
|
||||
"left join jlr_supplier_visual j on j.supplier_id = s.id " +
|
||||
"left join task_order_cost_his c on c.user_order_id = u.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"where j.jlr_user_id = "+logininfo.getId());
|
||||
}else{
|
||||
sql=new StringBuffer("select u.id id,u.code code,u.vin_no vin_no,s.name name,u.vehicle_point_address vehicle_point_address," +
|
||||
"b.name serviceName,u.create_time,u.order_status,c.other_amount other_amount,c.account_status account_status," +
|
||||
"c.settle_mileage_bc settle_mileage_bc,d.address address from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id " +
|
||||
"left join supplier s on s.id = t.service_supplier_id " +
|
||||
"left join jlr_supplier_visual j on j.supplier_id = s.id " +
|
||||
"left join task_order_cost_his c on c.user_order_id = u.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"where c.account_status in (4,6) and j.jlr_user_id = "+logininfo.getId());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(code)) {
|
||||
sql.append(" and u.vin_no like '%" + code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
sql.append(" and u.code like '%" + orderCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(rescueCompanyName)) {
|
||||
sql.append(" and s.name like '%" + rescueCompanyName + "%'");
|
||||
}
|
||||
if ("8".equals(check_state)){
|
||||
sql.append(" and (c.account_status = 2 or c.account_status = 3)");
|
||||
}else if(StringUtils.isNotBlank(check_state)){
|
||||
sql.append(" and c.account_status = "+check_state);
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and u.create_time >= '"+queryDate1+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and u.create_time <= '"+queryDate2+"'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取服务费用信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取服务费用信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","ORDER_CODE","VIN_NO","NAME","ADDRESS","SERVICE_NAME","CREATE_TIME","RECUESTATE","MONEY","ACCOUNTSTATE","MILE","DESTINATION"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject exportData(HttpServletRequest request, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state) {
|
||||
//创建集合
|
||||
List listExcel = new ArrayList();
|
||||
//声明一个json对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
//创建sql
|
||||
StringBuffer sql=new StringBuffer("select u.code code,u.vin_no vin_no,s.name name,u.vehicle_point_address vehicle_point_address," +
|
||||
"b.name serviceName,u.create_time,u.order_status,c.other_amount other_amount,c.account_status account_status," +
|
||||
"c.settle_mileage_bc settle_mileage_bc,d.address address from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id " +
|
||||
"left join supplier s on s.id = t.service_supplier_id " +
|
||||
"left join jlr_supplier_visual j on j.supplier_id = s.id " +
|
||||
"left join task_order_cost_his c on c.user_order_id = u.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"where j.jlr_user_id = "+logininfo.getId());
|
||||
//动态拼接
|
||||
if (StringUtils.isNotBlank(code)) {
|
||||
sql.append(" and u.vin_no like '%" + code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
sql.append(" and u.code like '%" + orderCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(rescueCompanyName)) {
|
||||
sql.append(" and s.name like '%" + rescueCompanyName + "%'");
|
||||
}
|
||||
if ("2".equals(check_state)){
|
||||
sql.append(" and (c.account_status = 2 or c.account_status = 3)");
|
||||
}else if(StringUtils.isNotBlank(check_state)){
|
||||
sql.append(" and c.account_status = "+check_state);
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and u.create_time >= '"+queryDate1+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and u.create_time <= '"+queryDate2+"'");
|
||||
}
|
||||
List list=null;
|
||||
try {
|
||||
//获取服务费用信息
|
||||
list = getRsBySql(sql.toString());
|
||||
OrderCheckExcelVO header = new OrderCheckExcelVO("案件编号", "VIN码", "供应商", "案件事发地", "案件目的地", "服务类型", "案发时间", "案件状态", "公里数", "结算状态", "金额");
|
||||
listExcel.add(header);
|
||||
if (list != null && list.size() > 0) {
|
||||
JSONArray array = UtilTools.listTojsonArray(list, new String[]{"CODE", "VIN_NO", "NAME", "ADDRESS", "SERVICE_NAME","CREATE_TIME","RECUESTATE", "MONEY","ACCOUNTSTATE","MILE","DESTINATION"});
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject json = array.getJSONObject(i);
|
||||
OrderCheckExcelVO vo = new OrderCheckExcelVO(
|
||||
json.getString("CODE"),
|
||||
json.getString("VIN_NO"),
|
||||
json.getString("NAME"),
|
||||
json.getString("ADDRESS"),
|
||||
json.getString("DESTINATION"),
|
||||
json.getString("SERVICE_NAME"),
|
||||
json.getString("CREATE_TIME"),
|
||||
MTextUtils.getRecueName(json.getString("RECUESTATE")),
|
||||
StringUtils.isBlank(json.getString("MILE")) ? "NA" : String.valueOf(json.getInt("MILE") / 1000),
|
||||
MTextUtils.getAccountState(json.getString("ACCOUNTSTATE")),
|
||||
getFee(json.getInt("RECUESTATE"),
|
||||
StringUtils.isBlank(json.getString("MONEY")) ? 0 : json.getInt("MONEY"),
|
||||
StringUtils.isBlank(json.getString("MONEY")) ? 0 : json.getInt("MONEY")
|
||||
)
|
||||
);
|
||||
listExcel.add(vo);
|
||||
}
|
||||
}
|
||||
//获取时间戳
|
||||
long dateTime = System.currentTimeMillis();
|
||||
//获取导出路径
|
||||
String path = request.getRealPath("attached") + File.separator
|
||||
+ logininfo.getName() + File.separator + dateTime + ".xlsx";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator
|
||||
+ "attached" + File.separator + logininfo.getName() + File.separator + dateTime + ".xlsx";
|
||||
boolean b = new UserOrderExcelVO().saveAll(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(String uid, String totalFee) {
|
||||
String sql="update task_order_cost_his set report_amount =" +totalFee+ ",guidance_amount = 800,account_status = 3 where user_order_id ="+uid;
|
||||
try{
|
||||
updateSql(sql);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getFee(int state, int total2, int other2) {
|
||||
if (state == 4 || state == 6) {
|
||||
return String.valueOf(total2 + other2);
|
||||
} else {
|
||||
return "NA";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.RoleDao;
|
||||
import com.zhongdao.jlr.business.vo.JLRMenu;
|
||||
import com.zhongdao.jlr.business.vo.JLRRMenu;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import com.zhongdao.jlr.pojo.JLRAuthority;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@Repository
|
||||
public class RoleDaoImpl extends BaseDaoHibernate implements RoleDao{
|
||||
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public Vo getRoleInfo(HttpServletRequest request, String name) {
|
||||
//获取sessions用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=new StringBuffer("select j.id,j.name,j.update_time from jlr_role j where j.delete_flag != 1 and j.id != "+ logininfo.getRole_id());
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
sql.append(" and j.name like '%" + name + "%'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" order by j.update_time desc limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取角色信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取角色信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
//将角色信息放入vo对象中
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","NAME","UPDATETIME"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JLRMenu> getTreeInfo() {
|
||||
List<JLRMenu> listes=new ArrayList<>();
|
||||
List list=null;
|
||||
try {
|
||||
String sql = "select b.id,b.parent_id,b.name,b.action " +
|
||||
"from (select parent_id " +
|
||||
"from (select r.id," +
|
||||
"r.role_id,r.menu_id,p.parent_id parent_id,p.id n,p.name,p.action" +
|
||||
" from jlr_role_authority r " +
|
||||
"inner join jlr_menu p on" +
|
||||
" r.menu_id=p.id ) m " +
|
||||
"group by " +
|
||||
"m.parent_id) m " +
|
||||
"inner join jlr_menu b on m.parent_id=b.id";
|
||||
//获取父级菜单信息
|
||||
list = getRsBySql(sql);
|
||||
//获取子菜单
|
||||
List<JLRRMenu> listess=getMenuInfo();
|
||||
//遍历菜单信息
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//将角色编号存入集合中
|
||||
List<JLRRMenu> lists=new ArrayList<>();
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
BaseMenu baseMenu = new BaseMenu();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
//声明一个tree对象
|
||||
JLRMenu jlrMenu= new JLRMenu();
|
||||
//将id和名称分别存入tree对象中
|
||||
jlrMenu.setId(Integer.valueOf(objects[0].toString()));
|
||||
jlrMenu.setText(objects[2] == null ? "" : objects[2].toString());
|
||||
if(listess != null && list.size()>0) {
|
||||
for (JLRRMenu listt : listess) {
|
||||
//如果是父节点的子节点
|
||||
if(listt.getParent_id() == jlrMenu.getId()){
|
||||
//则将字节点放如集合中
|
||||
lists.add(listt);
|
||||
}
|
||||
}
|
||||
}
|
||||
//将集合放入tree对象中
|
||||
jlrMenu.setChildren(lists);
|
||||
//将树对象放入集合中
|
||||
listes.add(jlrMenu);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return listes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRoleInfo(JLRRole jlrRole) {
|
||||
try {
|
||||
//添加或更新用户信息
|
||||
saveOrUpdate(jlrRole);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRolesInfo(JLRAuthority jlrAuthority) {
|
||||
try {
|
||||
//添加或更新权限信息
|
||||
saveOrUpdate(jlrAuthority);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JLRRole getUser(String id) {
|
||||
JLRRole jlrUser=null;
|
||||
try {
|
||||
//获取单个用户对象信息
|
||||
jlrUser=(JLRRole) getObjectHql("from JLRRole where id = "+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return jlrUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getMenu(String id) {
|
||||
List<BaseMenu> lists=new ArrayList<>();
|
||||
List list=null;
|
||||
try {
|
||||
String sql = "select j.id,j.parent_id,j.name,j.action from jlr_menu j inner join jlr_role_authority l on j.id = l.menu_id where role_id ="+id;
|
||||
//获取菜单信息
|
||||
list = getRsBySql(sql);
|
||||
//遍历菜单信息
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
BaseMenu baseMenu = new BaseMenu();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
baseMenu.setId(Integer.valueOf(objects[0].toString()));
|
||||
baseMenu.setParent_id(Integer.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
baseMenu.setName(objects[2] == null ? "" : objects[2].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(baseMenu);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
public List<JLRRMenu> getMenuInfo() {
|
||||
List<JLRRMenu> lists=new ArrayList<>();
|
||||
List list=null;
|
||||
try {
|
||||
String sql = "select l.id,l.parent_id,l.name,l.action from jlr_menu j inner join jlr_menu l on j.id = l.parent_id";
|
||||
//获取菜单信息
|
||||
list = getRsBySql(sql);
|
||||
//遍历菜单信息
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
JLRRMenu baseMenu = new JLRRMenu();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
baseMenu.setId(Integer.valueOf(objects[0].toString()));
|
||||
baseMenu.setParent_id(Integer.valueOf(objects[1] == null ? "0" : objects[1].toString()));
|
||||
baseMenu.setText(objects[2] == null ? "" : objects[2].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(baseMenu);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSupplier(Integer id) {
|
||||
try {
|
||||
deleteHql("delete JLRAuthority where role_id="+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.SupplierDao;
|
||||
import com.zhongdao.jlr.business.vo.Contract;
|
||||
import com.zhongdao.jlr.business.vo.Destination;
|
||||
import com.zhongdao.jlr.business.vo.Enterprise;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class SupplierDaoImpl extends BaseDaoHibernate implements SupplierDao{
|
||||
|
||||
@Override
|
||||
public Vo getContractInfo(HttpServletRequest request,String name,String id) {
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=new StringBuffer("select c.id,c.contarct_code,c.contract_name,c.remark,c.app_code,c.create_time from contract c " +
|
||||
"where c.id in (7049,7079,7050,7080) and c.level = 2 and c.delete_flag != 1 " +
|
||||
"and c.id not in (select contract_id from jlr_contract_visual where jlr_user_id = "+id+")");
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
sql.append(" and c.contract_name like '%" + name + "%'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取用户信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取用户信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
//将用户信息放入vo对象中
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","CODE","NAME","REMARK","APPCODE","CREATETIME"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Contract> getAssignContract(String id) {
|
||||
List<Contract> lists=new ArrayList<>();
|
||||
String sql="select c.id,c.contarct_code,c.contract_name,c.remark,c.app_code,c.create_time from contract c " +
|
||||
"left join jlr_contract_visual j " +
|
||||
"on j.contract_id = c. id " +
|
||||
"where j.jlr_user_id="+id;
|
||||
try {
|
||||
//获取指定合同信息
|
||||
List list = getRsBySql(sql);
|
||||
if (list != null && list.size() > 0) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
Contract contract = new Contract();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
contract.setId(Integer.valueOf(objects[0].toString()));
|
||||
contract.setName(objects[2] == null ? "" : objects[2].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(contract);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Destination> getAssignDestination(String id) {
|
||||
List<Destination> lists=new ArrayList<>();
|
||||
String sql="select c.id,c.name from contract_destination c " +
|
||||
"left join jlr_destination_visual j " +
|
||||
"on j.contract_destination_id = c.id " +
|
||||
"where j.jlr_user_id="+id;
|
||||
try {
|
||||
//获取指定目的地信息
|
||||
List list = getRsBySql(sql);
|
||||
if (list != null && list.size() > 0) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
Destination destination = new Destination();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
destination.setId(Integer.valueOf(objects[0].toString()));
|
||||
destination.setName(objects[1] == null ? "" : objects[1].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(destination);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enterprise> getAssignEnterprise(String id) {
|
||||
List<Enterprise> lists=new ArrayList<>();
|
||||
String sql="select s.id,s.name from supplier s " +
|
||||
"left join jlr_supplier_visual j " +
|
||||
"on s.id=j.supplier_id " +
|
||||
"where j.jlr_user_id="+id;
|
||||
try {
|
||||
//获取指定目的地信息
|
||||
List list = getRsBySql(sql);
|
||||
if (list != null && list.size() > 0) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
Enterprise enterprise = new Enterprise();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
enterprise.setId(Integer.valueOf(objects[0].toString()));
|
||||
enterprise.setName(objects[1] == null ? "" : objects[1].toString());
|
||||
//将对象放入集合中
|
||||
lists.add(enterprise);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getEnterpriseInfo(HttpServletRequest request,String name,String id) {
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=new StringBuffer("select s.id,s.name,s.code,s.phone_login_name,s.create_time from supplier s " +
|
||||
"where s.delete_flag != 1 " +
|
||||
"and s.id not in (select supplier_id from jlr_supplier_visual where jlr_user_id = "+id+")");
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
sql.append(" and s.name like '%" + name + "%'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取用户信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取用户信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
//将用户信息放入vo对象中
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","NAME","CODE","LOGINNAME","CREATETIME"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getDestination(HttpServletRequest request, String name,String id) {
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=new StringBuffer("select c.id,c.name,c.address,c.brand_name,c.create_time from contract_destination c " +
|
||||
"left join jlr_contract_visual j " +
|
||||
"on j.contract_id = c.contract_id " +
|
||||
"where c.delete_flag != 1 " +
|
||||
"and c.id not in (select contract_destination_id from jlr_destination_visual where jlr_user_id = "+id+") and j.jlr_user_id ="+id);
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
sql.append(" and c.name like '%" + name + "%'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//分页获取合同下的目的地信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取合同下的目的地信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
//将用户信息放入vo对象中
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"ID","NAME","ADDRESS","BRAND","CREATETIME"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertContractInfo(JLRUserContract jlrUserContract) {
|
||||
try {
|
||||
//为用户指定合同
|
||||
saveOrUpdate(jlrUserContract);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertDestinationInfo(JLRDestination jlrDestination) {
|
||||
try {
|
||||
//指定目的地
|
||||
saveOrUpdate(jlrDestination);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertEnterpriseInfo(JLRSupplier jlrSupplier) {
|
||||
try {
|
||||
//指定服务商
|
||||
saveOrUpdate(jlrSupplier);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDestinationInfo(int id,int uid) {
|
||||
try {
|
||||
//删除已指定的目的地信息
|
||||
deleteHql("delete JLRDestination where jlr_user_id = "+uid+" and contract_destination_id = "+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteEnterpriseInfo(int sid,int uid) {
|
||||
try {
|
||||
//删除已指定的供应商信息
|
||||
deleteHql("delete JLRSupplier where jlr_user_id = "+uid+" and supplier_id = "+sid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteContractInfo(int cid,int uid) {
|
||||
try {
|
||||
//删除已指定的合同信息
|
||||
deleteHql("delete JLRUserContract where jlr_user_id = "+uid+" and contract_id = "+cid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JLRUserContract> getContract(String id) {
|
||||
List<JLRUserContract> jlrUserContract=null;
|
||||
try {
|
||||
jlrUserContract=(List<JLRUserContract>) getRsByHql("from JLRUserContract where jlr_user_id = "+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return jlrUserContract;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.zhongdao.jlr.business.dao.impl;
|
||||
|
||||
import com.dubh.common.dao.hibernate.BaseDaoHibernate;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.UserInfoDao;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.business.vo.PageInfo;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUser;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class UserInfoDaoImpl extends BaseDaoHibernate implements UserInfoDao {
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Override
|
||||
public List<JLRRole> getRoleInfo() {
|
||||
//获取sessions用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
List<JLRRole> baseRole=null;
|
||||
try {
|
||||
//获取角色信息
|
||||
baseRole=(List<JLRRole>)getRsByHql("from JLRRole where delete_flag != 1 and id != "+logininfo.getRole_id());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return baseRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseJlr> getEnterpriseInfo() {
|
||||
//获取sessions用户信息
|
||||
LoginUserVo logininfo=(LoginUserVo)request.getSession().getAttribute("logininfo");
|
||||
List<EnterpriseJlr> enterpriseJlrs=null;
|
||||
try {
|
||||
//获取用户信息
|
||||
enterpriseJlrs=(List<EnterpriseJlr>)getRsByHql("from EnterpriseJlr");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return enterpriseJlrs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getUserInfo(HttpServletRequest request, String name, String phone,String role,String username) {
|
||||
Vo vo=new Vo();
|
||||
//声明一个分页对象
|
||||
PageInfo pageInfo=new PageInfo();
|
||||
//获取页数和一页显示多少行并将其放入对象中
|
||||
pageInfo.setPage(UtilTools.getPage(request));
|
||||
pageInfo.setRows(UtilTools.getRows(request));
|
||||
//sql动态拼接
|
||||
StringBuffer sql=new StringBuffer("select j.login_name,j.id,j.name,j.phone,j.email,r.name roleName,j.update_time " +
|
||||
"from jlr_user j " +
|
||||
"left join jlr_role r " +
|
||||
"on r.id=j.role_id " +
|
||||
"where j.role_id != 1 and j.delete_flag != 1");
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
sql.append(" and j.name like '%" + name + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
sql.append(" and j.phone like '%" + phone + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(role)) {
|
||||
sql.append(" and j.role_id = '"+ role +"'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
sql.append(" and j.login_name = '"+ username +"'");
|
||||
}
|
||||
String countSql=sql.toString();
|
||||
String info=sql.append(" order by j.update_time desc limit "+pageInfo.getCurrentIndex()+","+pageInfo.getRows()).toString();
|
||||
try {
|
||||
//获取用户信息总数
|
||||
List lists=getRsBySql(countSql);
|
||||
//分页获取用户信息
|
||||
List list = getRsBySql(info);
|
||||
if (list != null && list.size() > 0) {
|
||||
//将用户信息放入vo对象中
|
||||
vo.setRows(UtilTools.listTojsonArray(list, new String[]{"LOGINNAME","ID","NAME","PHONE","EMAIL","ROLENAME","UPDATETIME"}));
|
||||
}
|
||||
if(lists != null && lists.size() > 0) {
|
||||
vo.setTotal(lists.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateUserInfo(JLRUser user) {
|
||||
try {
|
||||
//添加或更新用户信息
|
||||
saveOrUpdate(user);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JLRUser getUser(String id) {
|
||||
JLRUser jlrUser=null;
|
||||
try {
|
||||
//获取单个用户对象信息
|
||||
jlrUser=(JLRUser) getObjectHql("from JLRUser where id ="+id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return jlrUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUser(JLRUser user) {
|
||||
try {
|
||||
if(user != null){
|
||||
user.setDelete_flag(1);
|
||||
}
|
||||
//添加或更新用户信息
|
||||
saveOrUpdate(user);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zhongdao.jlr.business.interceptor;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
public class UserInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final String LOGININFO = "logininfo";
|
||||
|
||||
// 拦截前处理
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object obj) throws Exception {
|
||||
|
||||
Object sessionObj = request.getSession().getAttribute(LOGININFO);
|
||||
if (sessionObj != null) {
|
||||
return true;
|
||||
}
|
||||
response.sendRedirect(request.getContextPath()+"/login.jsp");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 拦截后处理
|
||||
public void postHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object obj, ModelAndView mav)
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
// 全部完成后处理
|
||||
public void afterCompletion(HttpServletRequest request,
|
||||
HttpServletResponse response, Object obj, Exception e)
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zhongdao.jlr.business.listener;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class AutoRunServlet implements ServletContextListener{
|
||||
|
||||
public AutoRunServlet(){
|
||||
System.out.println("调用了构造方法");
|
||||
}
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
System.out.println(" ----------创建了Context created on " +
|
||||
new Date() + ".");
|
||||
}
|
||||
public void contextDestroyed(ServletContextEvent event) {
|
||||
System.out.println("--------销毁了Context destroyed on " +
|
||||
new Date() + ".");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.zhongdao.jlr.business.listener;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.orm.hibernate4.SessionHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
/**
|
||||
* 启动监听器
|
||||
*
|
||||
* @author Storezhang
|
||||
*/
|
||||
@Component
|
||||
public class StartupListener implements
|
||||
ApplicationListener<ContextRefreshedEvent> {
|
||||
@Resource
|
||||
private SessionFactory sessionFactory;
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent arg0) {
|
||||
System.out.println("-----所有Bean载入完成---");
|
||||
System.out.println("开始配置缓存");
|
||||
//解决Spring启动加载静态数据时报No Session found for current thread异常
|
||||
Session session = sessionFactory.openSession();
|
||||
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BaseService {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
public Map login(HttpServletRequest request,Map result,String username,String password);
|
||||
|
||||
/***
|
||||
* 获取菜单信息
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getMenuInfo();
|
||||
|
||||
/***
|
||||
* 获取父级菜单信息
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getParentMenuInfo();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.UserOrderViewVO;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口
|
||||
*/
|
||||
public interface CasesListService {
|
||||
|
||||
/**
|
||||
* 救援工单信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
Vo casesListService(String state,HttpServletRequest request, String caseCode, String frame_code, String
|
||||
rescueState, String createTime, String finishTime, String companyName,String plateNumber);
|
||||
|
||||
/***
|
||||
* 获取进店救援案件信息
|
||||
* @param request
|
||||
* @param caseCode
|
||||
* @param frame_code
|
||||
* @param createTime
|
||||
* @param finishTime
|
||||
* @return
|
||||
*/
|
||||
Vo caseEnterQuery(String state,HttpServletRequest request,String caseCode,String frame_code,String createTime,String finishTime);
|
||||
|
||||
/****
|
||||
* 获取案件详情信息
|
||||
* @return
|
||||
*/
|
||||
Vo caseEnterInfo(HttpServletRequest request,String caseCode,String tid);
|
||||
|
||||
/*
|
||||
* 故障三级信息
|
||||
*/
|
||||
JSONObject getTroubleCode(HttpServletRequest request) throws Exception;
|
||||
|
||||
/*
|
||||
* 详细页面保存
|
||||
*/
|
||||
JSONObject caseDetailSave(HttpServletRequest request) throws Exception;
|
||||
|
||||
/*
|
||||
* 导出报表
|
||||
*/
|
||||
JSONObject exportData(HttpServletRequest request) throws Exception;
|
||||
|
||||
/*
|
||||
* 导出报表CSV格式
|
||||
*/
|
||||
JSONObject exportCSVData(HttpServletRequest request,HttpServletResponse response) throws Exception;
|
||||
|
||||
/*
|
||||
* 求援完成确认
|
||||
*/
|
||||
net.sf.json.JSONObject completionOfRescue(String code) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.CouponRechargeJlr;
|
||||
import com.zhongdao.jlr.pojo.CouponRechargeJlrPO;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
|
||||
public interface CouponService {
|
||||
|
||||
/**
|
||||
* 代金券模糊搜索
|
||||
*/
|
||||
public Vo searchConsume(String vinCode, String electronicAccounts,String userPhone, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费记录
|
||||
*/
|
||||
public Vo getCouponConsume(String vin, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券充值记录
|
||||
*/
|
||||
public Vo getCouponRecharge(String vin, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费记录(整体)
|
||||
*/
|
||||
public Vo queryCouponConsume(String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String qureyDate1, String queryDate2, int page, int raws);
|
||||
|
||||
/*
|
||||
* 导出报表
|
||||
*/
|
||||
JSONObject exportData(HttpServletRequest request, String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String qureyDate1, String queryDate2) throws Exception;
|
||||
|
||||
/**
|
||||
* 代金券消费修改 撤回、同意付款
|
||||
*/
|
||||
public boolean updateConsumeState(String cId, String state);
|
||||
|
||||
/**
|
||||
* 代金券充值记录撤销
|
||||
*/
|
||||
public List<CouponRechargeJlrPO> revokeRecharge(String vinCode, double revokeRechargeCount);
|
||||
|
||||
/**
|
||||
* 代金卷账户密码短信发送
|
||||
*/
|
||||
boolean sendMsg(String phoneNum, String msgContent);
|
||||
|
||||
/**
|
||||
* 充值记录
|
||||
*/
|
||||
public Vo queryCouponRecharge(String vin, String account, String orderCode, String license, String phone, String qureyDate1, String queryDate2, int page, int raws);
|
||||
|
||||
|
||||
/***
|
||||
* 充值记录导出报表
|
||||
* @param request
|
||||
* @param vin
|
||||
* @param account
|
||||
* @param orderCode
|
||||
* @param phone
|
||||
* @param qureyDate1
|
||||
* @param queryDate2
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
JSONObject rechangeExportData(HttpServletRequest request, String vin, String account, String orderCode, String phone, String qureyDate1, String queryDate2) throws Exception;
|
||||
|
||||
/**
|
||||
* 代金券
|
||||
*/
|
||||
public Vo getCoupon(String vin, String electronicAccounts, int page, int raws);
|
||||
|
||||
/**
|
||||
* 代金券消费
|
||||
*/
|
||||
public Map consume(String createTime, String vinCode, Double consumeCount, Integer resccueCompanyCode, String reparieInfo, String hitchInfo, String remark, String epassword);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
|
||||
public interface EnterpriseService {
|
||||
|
||||
/***
|
||||
* 查询经销商信息
|
||||
* @param name
|
||||
* @param abbrCode
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
Vo searchEnterprise(String name,String abbrCode,
|
||||
Integer page, Integer rows);
|
||||
|
||||
/**
|
||||
* 删除经销商信息
|
||||
*/
|
||||
boolean deleteById(String id);
|
||||
|
||||
/**
|
||||
* 新增或者修改经销商信息
|
||||
*/
|
||||
boolean putEnterprise(EnterpriseJlr enterprise, String newPassword, String confirmPassword,String UID) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据ID获取经销商信息
|
||||
*/
|
||||
public EnterpriseJlr getById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取经销商报表信息
|
||||
*/
|
||||
JSONObject expordata(HttpServletRequest request, String name, String abbrCode);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.util.Vo;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
|
||||
public interface OrderCheckService {
|
||||
|
||||
/**
|
||||
* 订单核对信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
public Vo list(HttpServletRequest request, int page, int raws,String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state);
|
||||
|
||||
/**
|
||||
* 服务费用信息
|
||||
*
|
||||
* @param
|
||||
* @return 用户信息
|
||||
*/
|
||||
public Vo lists(HttpServletRequest request, int page, int raws, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state,String state);
|
||||
|
||||
/***
|
||||
* 导出
|
||||
* @param request
|
||||
* @param code
|
||||
* @param orderCode
|
||||
* @param queryDate1
|
||||
* @param rescueCompanyName
|
||||
* @param queryDate2
|
||||
* @param check_state
|
||||
* @return
|
||||
*/
|
||||
JSONObject exportData(HttpServletRequest request, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state);
|
||||
|
||||
/***
|
||||
* 修改服务费用信息
|
||||
* @return
|
||||
*/
|
||||
boolean updateInfo(String uid,String totalFee);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.JLRMenu;
|
||||
import com.zhongdao.jlr.business.vo.JLRRMenu;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
|
||||
public interface RoleService {
|
||||
|
||||
/***
|
||||
* 获取角色信息
|
||||
* @param request
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Vo getRoleInfo(HttpServletRequest request,String name);
|
||||
|
||||
/***
|
||||
* 获取树的信息
|
||||
* @return
|
||||
*/
|
||||
List<JLRMenu> getTreeInfo();
|
||||
|
||||
/***
|
||||
* 添加角色信息
|
||||
*/
|
||||
boolean updateRoleInfo(JLRRole jlrRole ,int[] ids);
|
||||
|
||||
/***
|
||||
* 根据编号获取角色信息
|
||||
* @param id
|
||||
*/
|
||||
JLRRole getRole(String id);
|
||||
|
||||
/***
|
||||
* 根据id获取菜单信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<BaseMenu> getMenu(String id);
|
||||
|
||||
/***
|
||||
* 删除角色信息
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
boolean deleteRole(String id,String name);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.vo.Contract;
|
||||
import com.zhongdao.jlr.business.vo.Destination;
|
||||
import com.zhongdao.jlr.business.vo.Enterprise;
|
||||
import com.zhongdao.jlr.pojo.JLRUserContract;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
public interface SupplierService{
|
||||
|
||||
/***
|
||||
*获取合同信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getContractInfo(HttpServletRequest request,String name,String id);
|
||||
|
||||
/***
|
||||
* 获取指定的合同信息
|
||||
* @return
|
||||
*/
|
||||
List<Contract> getAssignContract(String id);
|
||||
|
||||
/***
|
||||
* 获取指定的目的地信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Destination> geAssignDestination(String id);
|
||||
|
||||
/***
|
||||
* 获取指定的供应商信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Enterprise> geAssignEnterprise(String id);
|
||||
|
||||
/***
|
||||
*获取供应商信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getEnterpriseInfo(HttpServletRequest request,String name,String id);
|
||||
|
||||
/***
|
||||
*获取合同下的目的地信息并分页展示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Vo getDestination(HttpServletRequest request,String name,String id);
|
||||
|
||||
/***
|
||||
* 为用户指定合同
|
||||
* @return
|
||||
*/
|
||||
boolean insertContractInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 为用户指定目的地
|
||||
* @return
|
||||
*/
|
||||
boolean insertDestinationInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 为用户指定供应商
|
||||
* @return
|
||||
*/
|
||||
boolean insertEnterpriseInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 删除指定的合同
|
||||
* @return
|
||||
*/
|
||||
boolean deleteContractInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 删除指定的供应商
|
||||
* @return
|
||||
*/
|
||||
boolean deleteEnterpriseInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 删除指定的目的地
|
||||
* @return
|
||||
*/
|
||||
boolean deleteDestinationInfo(Integer id,int[] ids);
|
||||
|
||||
/***
|
||||
* 获取合同信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<JLRUserContract> getDestinationInfo(String id);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zhongdao.jlr.business.service;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 接口
|
||||
*/
|
||||
public interface UserInfoService {
|
||||
/***
|
||||
* 获取角色信息
|
||||
* @return
|
||||
*/
|
||||
List<JLRRole> getRoleInfo();
|
||||
|
||||
/***
|
||||
* 获取经销商信息
|
||||
* @return
|
||||
*/
|
||||
List<EnterpriseJlr> getEnterpriseInfo();
|
||||
|
||||
/***
|
||||
* 获取用户信息
|
||||
* @param request
|
||||
* @param name
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
Vo getUserInfo(HttpServletRequest request,String name,String phone,String role,String username);
|
||||
|
||||
/***
|
||||
* 添加或更改用户信息
|
||||
*/
|
||||
boolean updateUserInfo(JLRUser user);
|
||||
|
||||
/***
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
JLRUser getUser(String id);
|
||||
|
||||
/***
|
||||
* 根据编号删除用户
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
boolean deleteUser(JLRUser user);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
import com.zhongdao.jlr.business.dao.BaseDao;
|
||||
import com.zhongdao.jlr.business.service.BaseService;
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.pojo.*;
|
||||
import jodd.util.BCrypt;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "baseServiceImpl")
|
||||
public class BaseServiceImpl implements BaseService {
|
||||
|
||||
@Autowired
|
||||
private BaseDao dao;
|
||||
|
||||
@Override
|
||||
public Map login(HttpServletRequest request, Map result, String username, String password) {
|
||||
BaseUser entity = null;
|
||||
List<BaseUserRole> baseUserRoles=null;
|
||||
List<Integer> list=new ArrayList<>();
|
||||
try {
|
||||
if (username.length() > 0 && null != password) {
|
||||
//获取用户信息
|
||||
entity = (BaseUser) dao.getObjectHql("from BaseUser where delete_flag != 1 and login_name='" + username + "'");
|
||||
if (entity == null) {
|
||||
throw new Exception("登陆帐号不存在!");
|
||||
}
|
||||
//判断密码是否正确
|
||||
boolean ps=BCrypt.checkpw(password,entity.getPassword() );
|
||||
if (ps != true) {
|
||||
throw new Exception("密码错误!");
|
||||
}
|
||||
} else {
|
||||
|
||||
throw new Exception("非法用户!");
|
||||
|
||||
}
|
||||
LoginUserVo loginInfo = new LoginUserVo();
|
||||
loginInfo.setRole_id(entity.getRole_id());
|
||||
loginInfo.setId(entity.getId());
|
||||
loginInfo.setLogin_name(entity.getLogin_name());
|
||||
loginInfo.setName(entity.getName());
|
||||
loginInfo.setPhone(entity.getPhone());
|
||||
loginInfo.setEmail(entity.getEmail());
|
||||
loginInfo.setEnterpriseJlrId(entity.getEnterprise_id());
|
||||
request.getSession().setAttribute("logininfo", loginInfo);
|
||||
result.put("flag", "1");
|
||||
result.put("msg", "登录成功");
|
||||
} catch (Exception ex) {
|
||||
result.put("msg", ex.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getMenuInfo() {
|
||||
return dao.getMenuInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getParentMenuInfo() {
|
||||
return dao.getParentMenuInfo();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.CaseDao;
|
||||
import com.zhongdao.jlr.business.service.CasesListService;
|
||||
|
||||
import com.zhongdao.jlr.business.vo.LoginUserVo;
|
||||
import com.zhongdao.jlr.business.vo.UserOrderCSVVO;
|
||||
import com.zhongdao.jlr.business.vo.UserOrderExcelVO;
|
||||
import com.zhongdao.jlr.util.ExportCSVUtil;
|
||||
import com.zhongdao.jlr.util.MTextUtils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.util.RequestUtil.ReturnObjStr;
|
||||
|
||||
/**
|
||||
* 处理道路救援的业务
|
||||
*/
|
||||
@Service(value = "casesListServiceImpl")
|
||||
public class CasesListServiceImpl implements CasesListService {
|
||||
|
||||
@Autowired
|
||||
private CaseDao dao;
|
||||
|
||||
@Override
|
||||
public Vo casesListService(String state,HttpServletRequest request, String caseCode, String frame_code, String rescueState, String createTime, String finishTime, String companyName,String plateNumber) {
|
||||
return dao.casesListService(state,request,caseCode,frame_code,rescueState,createTime,finishTime,companyName,plateNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo caseEnterQuery(String state,HttpServletRequest request, String caseCode, String frame_code, String createTime, String finishTime) {
|
||||
return dao.caseEnterQuery(state,request,caseCode,frame_code,createTime,finishTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo caseEnterInfo(HttpServletRequest request, String caseCode,String tid) {
|
||||
return dao.caseEnterInfo(request,caseCode,tid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getTroubleCode(HttpServletRequest request) throws Exception {
|
||||
return dao.getTroubleCode(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject caseDetailSave(HttpServletRequest request) throws Exception {
|
||||
return dao.caseDetailSave(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject exportData(HttpServletRequest request) throws Exception {
|
||||
//获取参数
|
||||
String caseCode = request.getParameter("caseCode");
|
||||
String frame_code = request.getParameter("frame_code");
|
||||
String createTime = request.getParameter("createTime");
|
||||
String finishTime = request.getParameter("finishTime");
|
||||
String state = request.getParameter("state");
|
||||
//声明一个报表集合用来保存工单信息
|
||||
List listExcel = new ArrayList();
|
||||
String userName = null;
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
if (logininfo != null) {
|
||||
userName = logininfo.getLogin_name().toString();
|
||||
}
|
||||
//创建sql
|
||||
StringBuffer sql=null;
|
||||
if("0".equals(state)){
|
||||
sql = new StringBuffer("select DISTINCT u.id uid,u.tid tid,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.model model,u.plate_number plate_number,m.start_time start_time,j.level_name levelName," +
|
||||
"u.finish_time finish_time,t.level_name levelNames,d.name dName,d.brand_name brandName,e.dms_code dms_code," +
|
||||
"e.trouble_reason trouble_reason,e.mileage mileage,e.dphm dphm,e.arrive_time arrive_time,e.remaer remaer," +
|
||||
"e.choice_type choice_type,e.trouble_code trouble_code,e.repair repair,e.ref_time ref_time,e.finish_time finishes_time" +
|
||||
",e.hand_time hand_time,e.use_time use_time from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.order_status order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_member_service_group m on u.member_service_group_id=m.id " +
|
||||
"left join contract_trouble_level j on j.id = u.malfunction_level1 " +
|
||||
"left join contract_trouble_level t on t.id = u.malfunction_level2 " +
|
||||
"left join jlr_epqr w on w.order_id = u.id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"left join jlr_epqr e on e.task_order_id = u.tid " +
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) and " +
|
||||
"u.order_status in (21,23,25,28,31) " +
|
||||
"and u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id =" + logininfo.getId() + ")");
|
||||
}else{
|
||||
sql = new StringBuffer("select DISTINCT u.id uid,u.tid tid,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.model model,u.plate_number plate_number,m.start_time start_time,j.level_name levelName," +
|
||||
"u.finish_time finish_time,t.level_name levelNames,d.name dName,d.brand_name brandName,e.dms_code dms_code," +
|
||||
"e.trouble_reason trouble_reason,e.mileage mileage,e.dphm dphm,e.arrive_time arrive_time,e.remaer remaer," +
|
||||
"e.choice_type choice_type,e.trouble_code trouble_code,e.repair repair,e.ref_time ref_time,e.finish_time finishes_time" +
|
||||
",e.hand_time hand_time,e.use_time use_time from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.order_status order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_member_service_group m on u.member_service_group_id=m.id " +
|
||||
"left join contract_trouble_level j on j.id = u.malfunction_level1 " +
|
||||
"left join contract_trouble_level t on t.id = u.malfunction_level2 " +
|
||||
"left join jlr_epqr w on w.order_id = u.id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"left join jlr_epqr e on e.task_order_id = u.tid " +
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) and " +
|
||||
"u.order_status in (21,23,25,28,31) " +
|
||||
"and u.destination_code in (select contract_destination_id from jlr_destination_visual where jlr_user_id ="+logininfo.getId()+")");
|
||||
}
|
||||
//sql动态拼接
|
||||
if (StringUtils.isNotBlank(frame_code)) {
|
||||
sql.append(" and u.vin_no like '%" + frame_code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(caseCode)) {
|
||||
sql.append(" and u.code like '%" + caseCode + "%'");
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(createTime)) {
|
||||
sql.append(" and u.create_time >= '"+createTime+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(finishTime)) {
|
||||
sql.append(" and u.create_time <= '"+finishTime+"'");
|
||||
}
|
||||
sql.append(" order by u.create_time desc");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//获取进店工单案件详情信息
|
||||
List list = dao.getRsBySql(sql.toString());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (list != null && list.size() > 0) {
|
||||
UserOrderExcelVO header = new UserOrderExcelVO("CLUB_ID_NUMBER", "BREAKDOWN_DATE", "VIN", "CURRENT_MILEAGE", "COMPONENT_DESCRIPTION",
|
||||
"JLR_COMPONENT", "FAULT_DESCRIPTION", "VRT_CODE", "VFG_CODE", "COMPLETION_DESCRIPTION", "VERBATIM_COMMENTS", "INITIAL_DIAGNOSED_FAULT",
|
||||
"ATTENDING_RESOURCE", "ACCEPTED", "SUPPRESS", "SHORT_VIN", "CTRY_OF_INCIDENT", "DEALER_CODE_REPAIR", "DEALER_NAME_REPAIR");
|
||||
listExcel.add(header);
|
||||
//遍历获取到的进店工单信息并将其放入excel表中
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
UserOrderExcelVO userOrderExcelVO = new UserOrderExcelVO();
|
||||
userOrderExcelVO.setClubIdNumber(ReturnObjStr(objects[2]));
|
||||
userOrderExcelVO.setCtryOfIncident("CHN");
|
||||
userOrderExcelVO.setVerbatimComments(ReturnObjStr(objects[21]));
|
||||
userOrderExcelVO.setBreakdownDate(sdf.format(sdf.parse(ReturnObjStr(objects[3]))));
|
||||
userOrderExcelVO.setCurrentMileage(ReturnObjStr(objects[18]));
|
||||
userOrderExcelVO.setAttendingResource("sino");
|
||||
userOrderExcelVO.setDealerCodeRepair("sino");
|
||||
userOrderExcelVO.setDealerNameRepair("中道救援");
|
||||
userOrderExcelVO.setAttendingResource(ReturnObjStr(objects[6]));
|
||||
userOrderExcelVO.setDealerCodeRepair(ReturnObjStr(objects[15]));
|
||||
userOrderExcelVO.setDealerNameRepair(ReturnObjStr(objects[14]));
|
||||
String vin = ReturnObjStr(objects[4]);
|
||||
userOrderExcelVO.setVin(vin);
|
||||
userOrderExcelVO.setShortVin(vin.length() > 6 ? vin.substring(vin.length() - 6) : vin);
|
||||
userOrderExcelVO.setJlrComponent("");
|
||||
userOrderExcelVO.setAccepted("");
|
||||
userOrderExcelVO.setSuppress("");
|
||||
userOrderExcelVO.setComponentDescription(ReturnObjStr(objects[23]));
|
||||
userOrderExcelVO.setInitialDiagnosedFault(ReturnObjStr(objects[12]));
|
||||
userOrderExcelVO.setFaultDescription(MTextUtils.getReason(ReturnObjStr(objects[17])));
|
||||
userOrderExcelVO.setVrtCode("");
|
||||
userOrderExcelVO.setVfgCode("");
|
||||
userOrderExcelVO.setCompletionDescription(MTextUtils.getRepairResult(ReturnObjStr(objects[24])));
|
||||
listExcel.add(userOrderExcelVO);
|
||||
}
|
||||
//格式化日期
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dateTime = simpleDateFormat.format(new Date());
|
||||
//创建导出路径
|
||||
String path = request.getRealPath("attached") + File.separator
|
||||
+ userName + File.separator + "EPQR_" + dateTime + ".xlsx";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator
|
||||
+ "attached" + File.separator + userName + File.separator + "EPQR_" + dateTime + ".xlsx";
|
||||
boolean b = new UserOrderExcelVO().saveAll(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject exportCSVData(HttpServletRequest request,HttpServletResponse response) throws Exception {
|
||||
//获取参数
|
||||
String caseCode = request.getParameter("caseCode");
|
||||
String frame_code = request.getParameter("frame_code");
|
||||
String createTime = request.getParameter("createTime");
|
||||
String finishTime = request.getParameter("finishTime");
|
||||
String state = request.getParameter("state");
|
||||
//声明一个报表集合用来保存工单信息
|
||||
List listExcel = new ArrayList();
|
||||
String userName = null;
|
||||
//获取用户信息
|
||||
LoginUserVo logininfo = (LoginUserVo) request.getSession().getAttribute("logininfo");
|
||||
if (logininfo != null) {
|
||||
userName = logininfo.getLogin_name().toString();
|
||||
}
|
||||
//创建sql
|
||||
StringBuffer sql=null;
|
||||
if("0".equals(state)){
|
||||
sql = new StringBuffer("select DISTINCT u.id uid,u.tid tid,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.model model,u.plate_number plate_number,m.start_time start_time,j.level_name levelName," +
|
||||
"u.finish_time finish_time,t.level_name levelNames,d.name dName,d.brand_name brandName,e.dms_code dms_code," +
|
||||
"e.trouble_reason trouble_reason,e.mileage mileage,e.dphm dphm,e.arrive_time arrive_time,e.remaer remaer," +
|
||||
"e.choice_type choice_type,e.trouble_code trouble_code,e.repair repair,e.ref_time ref_time,e.finish_time finishes_time" +
|
||||
",e.hand_time hand_time,e.use_time use_time from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.order_status order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_member_service_group m on u.member_service_group_id=m.id " +
|
||||
"left join contract_trouble_level j on j.id = u.malfunction_level1 " +
|
||||
"left join contract_trouble_level t on t.id = u.malfunction_level2 " +
|
||||
"left join jlr_epqr w on w.order_id = u.id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"left join jlr_epqr e on e.task_order_id = u.tid " +
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) and " +
|
||||
"u.order_status in (21,23,25,28,31) " +
|
||||
"and u.contract_id in (select contract_id from jlr_contract_visual where jlr_user_id =" + logininfo.getId() + ")");
|
||||
}else{
|
||||
sql = new StringBuffer("select DISTINCT u.id uid,u.tid tid,u.code orderCode,u.create_time " +
|
||||
"create_time,u.vin_no vin_no,s.name name, " +
|
||||
"s.code code,b.name serviceName,u.model model,u.plate_number plate_number,m.start_time start_time,j.level_name levelName," +
|
||||
"u.finish_time finish_time,t.level_name levelNames,d.name dName,d.brand_name brandName,e.dms_code dms_code," +
|
||||
"e.trouble_reason trouble_reason,e.mileage mileage,e.dphm dphm,e.arrive_time arrive_time,e.remaer remaer," +
|
||||
"e.choice_type choice_type,e.trouble_code trouble_code,e.repair repair,e.ref_time ref_time,e.finish_time finishes_time" +
|
||||
",e.hand_time hand_time,e.use_time use_time from " +
|
||||
"(select u.code code,u.create_time,u.vin_no,u.order_status order_status," +
|
||||
"u.service_id,t.service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id=u.id " +
|
||||
"union select u.code code,u.create_time create_time,u.vin_no vin_no," +
|
||||
"u.order_status order_status,u.service_id service_id " +
|
||||
",t.service_supplier_id service_supplier_id,u.contract_id contract_id,u.contract_destination_id destination_code," +
|
||||
"u.model model,u.plate_number plate_number,u.member_service_group_id member_service_group_id,u.finish_time finish_time," +
|
||||
"u.malfunction_level1 malfunction_level1,u.malfunction_level2 malfunction_level2,u.id id,u.contract_destination_id contract_destination_id,t.id tid " +
|
||||
"from user_order u " +
|
||||
"left join task_order t on t.user_order_id=u.id " +
|
||||
") u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join contract_member_service_group m on u.member_service_group_id=m.id " +
|
||||
"left join contract_trouble_level j on j.id = u.malfunction_level1 " +
|
||||
"left join contract_trouble_level t on t.id = u.malfunction_level2 " +
|
||||
"left join jlr_epqr w on w.order_id = u.id " +
|
||||
"left join contract_destination d on d.id = u.contract_destination_id " +
|
||||
"left join jlr_epqr e on e.task_order_id = u.tid " +
|
||||
"where b.id in (1041,1050,1500,1501,1520,1521) and " +
|
||||
"u.order_status in (21,23,25,28,31) " +
|
||||
"and u.destination_code in (select contract_destination_id from jlr_destination_visual where jlr_user_id ="+logininfo.getId()+")");
|
||||
}
|
||||
//sql动态拼接
|
||||
if (StringUtils.isNotBlank(frame_code)) {
|
||||
sql.append(" and u.vin_no like '%" + frame_code + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(caseCode)) {
|
||||
sql.append(" and u.code like '%" + caseCode + "%'");
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotBlank(createTime)) {
|
||||
sql.append(" and u.create_time >= '"+createTime+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(finishTime)) {
|
||||
sql.append(" and u.create_time <= '"+finishTime+"'");
|
||||
}
|
||||
sql.append(" order by u.create_time desc");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//获取进店工单案件详情信息
|
||||
List list = dao.getRsBySql(sql.toString());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (list != null && list.size() > 0) {
|
||||
UserOrderCSVVO header = new UserOrderCSVVO("CLUB_ID_NUMBER", "BREAKDOWN_DATE", "VIN", "CURRENT_MILEAGE", "COMPONENT_DESCRIPTION",
|
||||
"JLR_COMPONENT", "FAULT_DESCRIPTION", "VRT_CODE", "VFG_CODE", "COMPLETION_DESCRIPTION", "VERBATIM_COMMENTS", "INITIAL_DIAGNOSED_FAULT",
|
||||
"ATTENDING_RESOURCE", "ACCEPTED", "SUPPRESS", "SHORT_VIN", "CTRY_OF_INCIDENT", "DEALER_CODE_REPAIR", "DEALER_NAME_REPAIR");
|
||||
listExcel.add(header);
|
||||
//遍历获取到的进店工单信息并将其放入excel表中
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
UserOrderCSVVO userOrderExcelVO = new UserOrderCSVVO();
|
||||
userOrderExcelVO.setClubIdNumber(ReturnObjStr(objects[2]));
|
||||
userOrderExcelVO.setCtryOfIncident("CHN");
|
||||
userOrderExcelVO.setVerbatimComments(ReturnObjStr(objects[21]));
|
||||
userOrderExcelVO.setBreakdownDate(sdf.format(sdf.parse(ReturnObjStr(objects[3]))));
|
||||
userOrderExcelVO.setCurrentMileage(ReturnObjStr(objects[18]));
|
||||
userOrderExcelVO.setAttendingResource("sino");
|
||||
userOrderExcelVO.setDealerCodeRepair("sino");
|
||||
userOrderExcelVO.setDealerNameRepair("中道救援");
|
||||
userOrderExcelVO.setAttendingResource(ReturnObjStr(objects[6]));
|
||||
userOrderExcelVO.setDealerCodeRepair(ReturnObjStr(objects[15]));
|
||||
userOrderExcelVO.setDealerNameRepair(ReturnObjStr(objects[14]));
|
||||
String vin = ReturnObjStr(objects[4]);
|
||||
userOrderExcelVO.setVin(vin);
|
||||
userOrderExcelVO.setShortVin(vin.length() > 6 ? vin.substring(vin.length() - 6) : vin);
|
||||
userOrderExcelVO.setJlrComponent("");
|
||||
userOrderExcelVO.setAccepted("");
|
||||
userOrderExcelVO.setSuppress("");
|
||||
userOrderExcelVO.setComponentDescription(ReturnObjStr(objects[23]));
|
||||
userOrderExcelVO.setInitialDiagnosedFault(ReturnObjStr(objects[12]));
|
||||
userOrderExcelVO.setFaultDescription(MTextUtils.getReason(ReturnObjStr(objects[17])));
|
||||
userOrderExcelVO.setVrtCode("");
|
||||
userOrderExcelVO.setVfgCode("");
|
||||
userOrderExcelVO.setCompletionDescription(MTextUtils.getRepairResult(ReturnObjStr(objects[24])));
|
||||
listExcel.add(userOrderExcelVO);
|
||||
}
|
||||
//格式化日期
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dateTime = simpleDateFormat.format(new Date());
|
||||
//创建导出路径
|
||||
String path = request.getRealPath("attached") + File.separator
|
||||
+ userName + File.separator + "EPQR_" + dateTime + ".csv";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator
|
||||
+ "attached" + File.separator + userName + File.separator + "EPQR_" + dateTime + ".csv";
|
||||
boolean b = ExportCSVUtil.doExport(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.sf.json.JSONObject completionOfRescue(String code) throws Exception {
|
||||
//声明一个解析图片的路径
|
||||
String url = "http://192.168.1.220:8888";
|
||||
//声明一个对象
|
||||
net.sf.json.JSONObject jsonObject=null;
|
||||
String sql = "select u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,u.arrive_time arrive_time," +
|
||||
"u.finish_time finish_time,s.name supplier_name,s.code supplier_code,b.name name,i.images images from " +
|
||||
"(select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order u " +
|
||||
"left join task_order t on t.user_order_id = u.id " +
|
||||
"union select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id) u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join order_images i on i.order_id = u.id " +
|
||||
"where u.code = '" + code +"' and i.task_status =19001";
|
||||
String Hsql="select u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,u.arrive_time arrive_time," +
|
||||
"u.finish_time finish_time,s.name supplier_name,s.code supplier_code,b.name name,i.images images from " +
|
||||
"(select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order u " +
|
||||
"left join task_order t on t.user_order_id = u.id " +
|
||||
"union select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id) u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"left join order_images i on i.order_id = u.id " +
|
||||
"where u.code = '" + code +"' and i.task_status =14001";
|
||||
String sqls="select u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,u.arrive_time arrive_time," +
|
||||
"u.finish_time finish_time,s.name supplier_name,s.code supplier_code,b.name name from " +
|
||||
"(select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order u " +
|
||||
"left join task_order t on t.user_order_id = u.id " +
|
||||
"union select u.id id,u.code code,u.vin_no vin_no,u.model model,u.malfunction_remark malfunction_remark," +
|
||||
"u.vehicle_point_address vehicle_point_address,u.destination_address destination_address,u.create_time create_time,t.arrive_time arrive_time," +
|
||||
"t.finish_time finish_time,t.task_status task_status,u.service_id service_id,t.service_supplier_id service_supplier_id from user_order_his u " +
|
||||
"left join task_order_his t on t.user_order_id = u.id) u " +
|
||||
"left join supplier s on u.service_supplier_id = s.id " +
|
||||
"left join base_service b on b.id = u.service_id " +
|
||||
"where u.code = '" + code +"'";
|
||||
try {
|
||||
//声明一个对象
|
||||
net.sf.json.JSONObject jsonObjects=null;
|
||||
//获取车主签名图片及救援详情信息
|
||||
List list = dao.getRsBySql(sql);
|
||||
//获取客户接车签名图片及救援信息
|
||||
List list1=dao.getRsBySql(Hsql);
|
||||
//获取救援详情信息
|
||||
List list2=dao.getRsBySql(sqls);
|
||||
if (list != null && list.size() > 0) {
|
||||
//若两张图片都有则将图片路径放入对象中
|
||||
jsonObject=UtilTools.listTojsonObject(list, new String[]{"ORDER_CODE", "VIN_NO", "MODEL", "MAL_REMARK", "START_ADDRESS", "DESTINATION_ADDRESS", "CREATE_TIME","ARRIVE_TIME","FINISH_TIME","NAME","CODE","SERVICE_TIME","URL"});
|
||||
if (list1 != null && list1.size() > 0) {
|
||||
jsonObjects=UtilTools.listTojsonObject(list1, new String[]{"ORDER_CODE", "VIN_NO", "MODEL", "MAL_REMARK", "START_ADDRESS", "DESTINATION_ADDRESS", "CREATE_TIME","ARRIVE_TIME","FINISH_TIME","NAME","CODE","SERVICE_TIME","URL"});
|
||||
jsonObject.put("URLS",jsonObjects.get("URL"));
|
||||
}else{
|
||||
jsonObject.put("URLS","");
|
||||
}
|
||||
}else{
|
||||
//若两张图片都没有则将救援数据放入对象中
|
||||
if (list1 != null && list1.size() > 0) {
|
||||
jsonObject=UtilTools.listTojsonObject(list1, new String[]{"ORDER_CODE", "VIN_NO", "MODEL", "MAL_REMARK", "START_ADDRESS", "DESTINATION_ADDRESS", "CREATE_TIME","ARRIVE_TIME","FINISH_TIME","NAME","CODE","SERVICE_TIME","URL"});
|
||||
jsonObject.put("URLS",jsonObject.get("URL"));
|
||||
jsonObject.put("URL","");
|
||||
}else{
|
||||
if(list2 != null && list2.size()>0){
|
||||
jsonObject=UtilTools.listTojsonObject(list2, new String[]{"ORDER_CODE", "VIN_NO", "MODEL", "MAL_REMARK", "START_ADDRESS", "DESTINATION_ADDRESS", "CREATE_TIME","ARRIVE_TIME","FINISH_TIME","NAME","CODE","SERVICE_TIME"});
|
||||
jsonObject.put("URL","");
|
||||
jsonObject.put("URLS","");
|
||||
}
|
||||
}
|
||||
}
|
||||
//截取图片路径动态拼接
|
||||
String urls=jsonObject.getString("URL");
|
||||
String urll=jsonObject.getString("URLS");
|
||||
if(urls.contains("IMAGE_URL_NEW")){
|
||||
String urles=urls.substring(13);
|
||||
jsonObject.put("URL",url+urles);
|
||||
}
|
||||
if(urll.contains("IMAGE_URL_NEW")){
|
||||
String urles=urll.substring(13);
|
||||
jsonObject.put("URLS",url+urles);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.CouponDao;
|
||||
import com.zhongdao.jlr.business.service.CouponService;
|
||||
|
||||
import com.zhongdao.jlr.business.vo.*;
|
||||
import com.zhongdao.jlr.pojo.CouponConsumeJlrPO;
|
||||
import com.zhongdao.jlr.pojo.CouponRechargeJlrPO;
|
||||
import com.zhongdao.jlr.pojo.JLRCoupon;
|
||||
import com.zhongdao.jlr.util.MTextUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static com.util.RequestUtil.ReturnObjStr;
|
||||
|
||||
/***
|
||||
* 处理代金券的业务
|
||||
*/
|
||||
|
||||
@Service(value = "couponServiceImpl")
|
||||
public class CouponServiceImpl implements CouponService {
|
||||
|
||||
@Autowired
|
||||
private CouponDao dao;
|
||||
|
||||
@Override
|
||||
public Vo searchConsume(String vinCode, String electronicAccounts,
|
||||
String userPhone, int page, int raws) {
|
||||
|
||||
return dao.searchConsume(vinCode, electronicAccounts,userPhone, page, raws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCouponConsume(String vin, int page, int raws) {
|
||||
return dao.getCouponConsume(vin, page, raws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCouponRecharge(String vin, int page, int raws) {
|
||||
return dao.getCouponRecharge(vin, page, raws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo queryCouponConsume(String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String qureyDate1, String queryDate2, int page, int raws) {
|
||||
return dao.queryCouponConsume(vin, account, RecuseCompanyName, rescueCompanyCode, license, phone, state, qureyDate1, queryDate2, page, raws);
|
||||
}
|
||||
@Override
|
||||
public JSONObject exportData(HttpServletRequest request, String vin, String account, String RecuseCompanyName, String rescueCompanyCode, String license, String phone, String state, String queryDate1, String queryDate2) {
|
||||
//声明一个json对象用来存储导出报表的信息
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//声明一个集合用来接收代金券消费记录的数据
|
||||
List list = null;
|
||||
//声明一个导出报表集合用来存储代金券消费记录信息
|
||||
List listExcel = new ArrayList();
|
||||
//sql动态拼接
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT c.id,c.vin_code,c.consume_count,c.electronic_accounts,r.user_phone,r.license,e.NAME,c.settlement_state,c.CONSUME_TIME,c.reparie_info,c.hitch_info,c.settle_time,c.create_time,c.remark\n" +
|
||||
"FROM jlr_coupon_consume c LEFT JOIN jlr_coupon r ON c.VIN_CODE = r.VIN_CODE\n" +
|
||||
"LEFT JOIN jlr_enterprise e on c.enterprise_id = e.ID\n where 1=1 ");
|
||||
if (StringUtils.isNotBlank(vin)) {
|
||||
sql.append(" and c.VIN_CODE like '%" + vin + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(account)) {
|
||||
sql.append(" and c.electronic_accounts like '%" + account + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(RecuseCompanyName)) {
|
||||
sql.append(" and e.NAME like '%" + RecuseCompanyName + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
sql.append(" and r.USER_PHONE like '%" + phone + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(license)) {
|
||||
sql.append(" and r.LICENSE like '%" + license + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(state)) {
|
||||
sql.append(" and c.settlement_state = '" + state + "'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(rescueCompanyCode)) {
|
||||
sql.append(" and c.enterprise_id = '" + rescueCompanyCode + "'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and c.CONSUME_TIME >= '"+queryDate1+"'");
|
||||
}
|
||||
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and c.CONSUME_TIME <= '"+queryDate2+"'");
|
||||
}
|
||||
try {
|
||||
//获取代金券消费记录信息
|
||||
list = dao.getRsBySql(sql.toString());
|
||||
//遍历代金券消费记录数据,并将其放入消费记录实体类中,再将实体类加入集合中
|
||||
if (list != null && list.size() > 0) {
|
||||
ConsumeQueryExcelVO header = new ConsumeQueryExcelVO("VIN码", "电子账户", "手机号码", "车牌号", "消费时间", "消费金额", "经销商", "审批状态");
|
||||
listExcel.add(header);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ConsumeQueryExcelVO consumeQueryExcelVO = new ConsumeQueryExcelVO();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
consumeQueryExcelVO.setVinCode(ReturnObjStr(objects[1]));
|
||||
consumeQueryExcelVO.setElectronicccounts(ReturnObjStr(objects[3]));
|
||||
consumeQueryExcelVO.setUserPhone(ReturnObjStr(objects[4]));
|
||||
consumeQueryExcelVO.setLicense(ReturnObjStr(objects[5]));
|
||||
//格式化日期
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
Date date=sdf.parse(ReturnObjStr(objects[8]));
|
||||
consumeQueryExcelVO.setConsumeTime(sdf.format(date));
|
||||
consumeQueryExcelVO.setConsumeCount(ReturnObjStr(objects[2]));
|
||||
consumeQueryExcelVO.setName(ReturnObjStr(objects[6]));
|
||||
consumeQueryExcelVO.setState(transState(ReturnObjStr(objects[7])));
|
||||
listExcel.add(consumeQueryExcelVO);
|
||||
}
|
||||
//时间格式转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
//获取当前时间并将其转换为string字符串
|
||||
String dateTime = simpleDateFormat.format(new Date());
|
||||
//导出报表路径
|
||||
String path = request.getRealPath("attached") + File.separator + "consumption_record_" + dateTime + ".xlsx";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator
|
||||
+ "attached" + File.separator + "consumption_record_" + dateTime + ".xlsx";
|
||||
boolean b = new ConsumeQueryExcelVO().saveAll(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject;
|
||||
|
||||
}
|
||||
|
||||
/****
|
||||
* 根据状态码返回对应的结果信息
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private String transState(String value) {
|
||||
switch (value) {
|
||||
case "0":
|
||||
return "未结算";
|
||||
case "1":
|
||||
return "未结算";
|
||||
case "5":
|
||||
return "提交结算";
|
||||
case "10":
|
||||
return "同意付款";
|
||||
case "100":
|
||||
return "已付款";
|
||||
case "101":
|
||||
return "已撤销";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateConsumeState(String cId, String state) {
|
||||
List<CouponRechargeJlrPO> couponRechargeJlrList = new ArrayList<CouponRechargeJlrPO>();
|
||||
//如果是撤销这需要撤销充值记录的变动
|
||||
if ("101".equals(state)) {
|
||||
//以,分割id
|
||||
String[] ids = cId.split(",");
|
||||
for (String id : ids) {
|
||||
CouponConsumeJlrPO consumejlr = null;
|
||||
try {
|
||||
//获取消费记录信息
|
||||
consumejlr = (CouponConsumeJlrPO) dao.getObjectHql("from CouponConsumeJlrPO where id=" + id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
//获取充值记录信息
|
||||
List<CouponRechargeJlrPO> list = revokeRecharge(consumejlr.getVin_code(), consumejlr.getConsume_count());
|
||||
if (list != null) {
|
||||
couponRechargeJlrList.addAll(list);
|
||||
}
|
||||
}
|
||||
if (couponRechargeJlrList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//更改状态(撤销充值记录)
|
||||
return dao.updateConsumeState(couponRechargeJlrList, cId, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CouponRechargeJlrPO> revokeRecharge(String vinCode, double revokeRechargeCount) {
|
||||
//声明一个集合用来存储充值记录信息
|
||||
List<CouponRechargeJlrPO> couponRechargeJlrList = null;
|
||||
try {
|
||||
//获取用户的充值记录
|
||||
couponRechargeJlrList = dao.getRsByHql("from CouponRechargeJlrPO where CONSUME_COUNT>0 and VIN_CODE='" + vinCode + "' and overdue_time>NOW() order by overdue_time desc");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return couponRechargeJlrList;
|
||||
}
|
||||
//计算代金劵充值应该退回的充值记录
|
||||
List<CouponRechargeJlrPO> revokeCouponRechargeJlrList = new ArrayList<CouponRechargeJlrPO>();
|
||||
double b = revokeRechargeCount;
|
||||
//遍历用户的代金券充值记录
|
||||
for (CouponRechargeJlrPO couponRechargeJlr : couponRechargeJlrList) {
|
||||
//获取用户的消费金额
|
||||
double c = couponRechargeJlr.getConsume_count();
|
||||
if (c > 0) {
|
||||
//如果用户的代金券充值金额大于用户的代金券消费金额
|
||||
if (b >= c) {
|
||||
//更新用户代金券的消费金额为0.0
|
||||
couponRechargeJlr.setConsume_count(0.0F);
|
||||
b = b - c;
|
||||
revokeCouponRechargeJlrList.add(couponRechargeJlr);
|
||||
continue;
|
||||
} else {
|
||||
//更新用户的代金券消费金额
|
||||
couponRechargeJlr.setConsume_count(Float.valueOf(String.valueOf(Double.parseDouble(couponRechargeJlr.getConsume_count().toString()) - b)));
|
||||
revokeCouponRechargeJlrList.add(couponRechargeJlr);
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return couponRechargeJlrList;
|
||||
}
|
||||
@Override
|
||||
public boolean sendMsg(String phoneNum, String msgContent) {
|
||||
//String send_url = "http://sms.10690221.com/hy/?uid=20016&auth=8827d737029bc0950a90cf9ce5946ce9&expid=0&encode=GBK";
|
||||
String send_url = "http://sms.10690221.com/hy/?uid=20016&auth=093627dd3b2b54900dcd355fd92b8f91&expid=0&encode=GBK";
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
send_url += "&mobile=" + phoneNum + "&msg=" + URLEncoder.encode(msgContent, "GBK");
|
||||
StringBuffer readOneLineBuff = new StringBuffer();
|
||||
String content = "";
|
||||
URL url = new URL(send_url);
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(1000);
|
||||
conn.setReadTimeout(1000);
|
||||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line = "";
|
||||
while ((line = reader.readLine()) != null) {
|
||||
readOneLineBuff.append(line);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
content = readOneLineBuff.toString();
|
||||
|
||||
if ("0".equals(content.split(",")[0])) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo queryCouponRecharge(String vin, String account, String orderCode, String license, String phone, String qureyDate1, String queryDate2, int page, int raws) {
|
||||
return dao.queryCouponRecharge(vin, account, orderCode, license, phone, qureyDate1, queryDate2, page, raws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject rechangeExportData(HttpServletRequest request, String vin, String account, String orderCode, String phone, String queryDate1, String queryDate2) throws Exception {
|
||||
{
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List list = null;
|
||||
List listExcel = new ArrayList();
|
||||
//sql动态拼接
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT c.ID,c.VIN_CODE,c.task_order_id,c.RECHARGE_TIME,c.RECHARGE_COUNT,c.SEATE_NAME,c.REMARK,c.SERVICE_NAME,c.OVERDUE_TIME,c.CONSUME_COUNT,r.ELECTRONIC_ACCOUNTS,c.CREATE_TIME, " +
|
||||
"r.LICENSE, r.USER_PHONE\n" +
|
||||
"FROM jlr_coupon_recharge c LEFT JOIN jlr_coupon r ON c.VIN_CODE = r.VIN_CODE where 1=1 ");
|
||||
if (StringUtils.isNotBlank(vin)) {
|
||||
sql.append(" and c.VIN_CODE like '%" + vin + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(account)) {
|
||||
sql.append(" and r.ELECTRONIC_ACCOUNTS like '%" + account + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
sql.append(" and c.task_order_id like '%" + orderCode + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
sql.append(" and r.USER_PHONE like '%" + phone + "%'");
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryDate1)) {
|
||||
sql.append(" and c.RECHARGE_TIME >= '"+queryDate1+"'");
|
||||
}
|
||||
// 结束时间
|
||||
if (StringUtils.isNotBlank(queryDate2)) {
|
||||
sql.append(" and c.RECHARGE_TIME <= '"+queryDate2+"'");
|
||||
}
|
||||
|
||||
sql.append("ORDER BY CREATE_TIME DESC");
|
||||
try {
|
||||
list = dao.getRsBySql(sql.toString());
|
||||
//获取充值记录信息并将其遍历,放入实例化对象中,再将对象加入集合中
|
||||
if (list != null && list.size() > 0) {
|
||||
RechangeQueryExcelVO header = new RechangeQueryExcelVO("VIN码", "电子账户", "手机号码", "车牌号", "服务类型", "案件编号", "充值金额", "充值时间", "到期时间");
|
||||
listExcel.add(header);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
RechangeQueryExcelVO rechangeQueryExcelVO = new RechangeQueryExcelVO();
|
||||
Object[] objects = (Object[]) list.get(i);
|
||||
rechangeQueryExcelVO.setVinCode(ReturnObjStr(objects[1]));
|
||||
rechangeQueryExcelVO.setElectronicAccounts(ReturnObjStr(objects[10]));
|
||||
rechangeQueryExcelVO.setUserPhone(ReturnObjStr(objects[13]));
|
||||
rechangeQueryExcelVO.setLicense(ReturnObjStr(objects[12]));
|
||||
rechangeQueryExcelVO.setServiceType(ReturnObjStr(objects[5]));
|
||||
rechangeQueryExcelVO.setcaseCode(ReturnObjStr(objects[2]));
|
||||
//格式化日期
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
Date date=sdf.parse(ReturnObjStr(objects[3]));
|
||||
rechangeQueryExcelVO.setRechargeTime(sdf.format(date));
|
||||
rechangeQueryExcelVO.setRechargeCount(ReturnObjStr(objects[4]));
|
||||
Date overDate=sdf.parse(ReturnObjStr(objects[8]));
|
||||
rechangeQueryExcelVO.setOverdueTime(sdf.format(overDate));
|
||||
listExcel.add(rechangeQueryExcelVO);
|
||||
}
|
||||
|
||||
//String s = URLEncoder.encode("充值记录", "GBK");
|
||||
//时间格式转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
//获取当前时间并转换为字符串
|
||||
String dateTime = simpleDateFormat.format(new Date());
|
||||
//到处报表路径
|
||||
String path = request.getRealPath("attached") + File.separator + "recharge_record_" + dateTime + ".xlsx";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator
|
||||
+ "attached" + File.separator + "recharge_record_" + dateTime + ".xlsx";
|
||||
boolean b = new RechangeQueryExcelVO().saveAll(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getCoupon(String vin, String electronicAccounts, int page, int raws) {
|
||||
return dao.getCoupon(vin, electronicAccounts, page, raws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map consume(String consumeTime, String vinCode, Double consumeCount,
|
||||
Integer enterpriseJlrId, String reparieInfo, String hitchInfo, String remark, String epassword) {
|
||||
//声明一个Map集合用来存储结果集信息
|
||||
Map<String, Object> map = new HashMap();
|
||||
map.put("status", false);
|
||||
try {
|
||||
//判断密码是否正确
|
||||
JLRCoupon conponjlr = (JLRCoupon) dao.getObjectHql("from JLRCoupon where vin_code='" + vinCode + "' and e_password='" + epassword + "'");
|
||||
if (conponjlr == null) {
|
||||
map.put("msg", "消费密码不正确");
|
||||
return map;
|
||||
}
|
||||
|
||||
//查询该用户的充值记录
|
||||
List<CouponRechargeJlrPO> couponRechargeJlrList = dao.getRsByHql("from CouponRechargeJlrPO where VIN_CODE='" + vinCode + "' and recharge_count>ifNull(consume_count,0) and overdue_time>NOW() order by overdue_time");
|
||||
double balance = 0;//余额
|
||||
if (couponRechargeJlrList != null && couponRechargeJlrList.size() > 0) {
|
||||
for (CouponRechargeJlrPO couponRechargeJlr : couponRechargeJlrList) {
|
||||
balance += (couponRechargeJlr.getRecharge_count() - MTextUtils.stringToDouble(couponRechargeJlr.getConsume_count()));
|
||||
}
|
||||
} else {
|
||||
map.put("msg", "余额不足");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
//余额小于消费金额
|
||||
if (balance < consumeCount) {
|
||||
map.put("msg", "余额不足");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
//计算代金劵消费
|
||||
List<CouponRechargeJlrPO> consumeCouponRechargeJlrList = new ArrayList<CouponRechargeJlrPO>();
|
||||
//声明本次的消费金额
|
||||
double b = consumeCount;
|
||||
//遍历所有的充值信息(充值金额大于消费金额且没有过期)
|
||||
for (CouponRechargeJlrPO couponRechargeJlr : couponRechargeJlrList) {
|
||||
double c = couponRechargeJlr.getRecharge_count() - MTextUtils.stringToDouble(couponRechargeJlr.getConsume_count());
|
||||
if (c > 0) {
|
||||
if (c >= b) {
|
||||
String s=String.valueOf(b + MTextUtils.stringToDouble(couponRechargeJlr.getConsume_count()));
|
||||
couponRechargeJlr.setConsume_count(Float.valueOf(s));
|
||||
consumeCouponRechargeJlrList.add(couponRechargeJlr);
|
||||
break;
|
||||
} else {
|
||||
b = b - c;
|
||||
couponRechargeJlr.setConsume_count(couponRechargeJlr.getRecharge_count());
|
||||
consumeCouponRechargeJlrList.add(couponRechargeJlr);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//声明一个消费记录实体类
|
||||
CouponConsumeJlrPO conponConsumejlr = new CouponConsumeJlrPO();
|
||||
conponConsumejlr.setElectronic_accounts(conponjlr.getElectronic_accounts());
|
||||
conponConsumejlr.setVin_code(vinCode);
|
||||
conponConsumejlr.setConsume_count(Float.valueOf(String.valueOf(consumeCount)));
|
||||
conponConsumejlr.setHitch_info(hitchInfo);
|
||||
conponConsumejlr.setEnterprise_id(enterpriseJlrId);
|
||||
conponConsumejlr.setReparie_info(reparieInfo);
|
||||
conponConsumejlr.setRemark(remark);
|
||||
conponConsumejlr.setSettlement_state(0);
|
||||
conponConsumejlr.setCreate_time(new Date());
|
||||
conponConsumejlr.setUpdate_time(new Date());
|
||||
conponConsumejlr.setSettle_time(new Date());
|
||||
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
|
||||
conponConsumejlr.setConsume_time(format1.parse(consumeTime));
|
||||
//临时主键生成
|
||||
conponConsumejlr.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
if (dao.consume(conponConsumejlr, consumeCouponRechargeJlrList)) {
|
||||
map.put("status", true);
|
||||
return map;
|
||||
} else {
|
||||
map.put("msg", "数据出错!");
|
||||
return map;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("msg", "数据出错!");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.UtilTools;
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.EnterpriseDao;
|
||||
import com.zhongdao.jlr.business.service.EnterpriseService;
|
||||
import com.zhongdao.jlr.business.vo.EnterpriseExcelVO;
|
||||
import com.zhongdao.jlr.pojo.BaseUser;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import com.zhongdao.jlr.util.GeoAddressCenter;
|
||||
import jodd.util.BCrypt;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 处理经销商维护的业务
|
||||
*/
|
||||
@Service(value = "enterpriseServiceImpl")
|
||||
public class EnterpriseServiceImpl implements EnterpriseService {
|
||||
|
||||
@Autowired
|
||||
private EnterpriseDao enterpriseDao;
|
||||
|
||||
@Override
|
||||
public Vo searchEnterprise(String name, String abbrCode,
|
||||
Integer page, Integer rows) {
|
||||
return enterpriseDao.searchEnterprise(name,abbrCode,page, rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
return enterpriseDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putEnterprise(EnterpriseJlr enterprise, String newPassword, String confirmPassword,String UID) throws
|
||||
Exception {
|
||||
//声明一个用户对象
|
||||
List<BaseUser> systemUser =new ArrayList<>();
|
||||
String sql=null;
|
||||
//根据供应商id获取用户信息
|
||||
if(UID == null) {
|
||||
sql = "select id from jlr_user where enterprise_id is not null and enterprise_id = "+ enterprise.getId();
|
||||
}else{
|
||||
sql = "select id from jlr_user where enterprise_id is not null and enterprise_id= "+ enterprise.getId()+ " and id = "+UID;
|
||||
}
|
||||
List list=enterpriseDao.getRsBySql(sql);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
//声明一个菜单对象并将信息放入对象里面
|
||||
BaseUser baseUser = new BaseUser();
|
||||
baseUser.setId((Integer)list.get(i));
|
||||
//将对象放入集合中
|
||||
systemUser.add(baseUser);
|
||||
}
|
||||
//如果没有供应商id说明此操作为添加
|
||||
if (enterprise.getId() == null || enterprise.getId() < 1) {
|
||||
//临时主键生成
|
||||
enterprise.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
//声明一个当前时间的对象
|
||||
Date date=new Date();
|
||||
enterprise.setCreate_time(date);
|
||||
}
|
||||
//如果经纬度不为空则根据经纬度获取地区编码,并将其放入供应商对象中
|
||||
if (enterprise.getLon() != null && enterprise.getLat() != null) {
|
||||
String areaCode = GeoAddressCenter.getGeoAdcode(enterprise.getLon() + "", enterprise.getLat() + "");
|
||||
enterprise.setArea_code(areaCode);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
//如果用户信息不为空则更新用户信息
|
||||
if (systemUser != null && !TextUtils.isEmpty(newPassword)) {
|
||||
for(BaseUser baseUser:systemUser){
|
||||
String password=BCrypt.hashpw(newPassword,BCrypt.gensalt());
|
||||
baseUser.setPassword(password);
|
||||
enterpriseDao.putSystemUser(baseUser);
|
||||
}
|
||||
}
|
||||
Date updateDate=new Date();
|
||||
enterprise.setUpdate_time(updateDate);
|
||||
//添加或修改用户信息
|
||||
return enterpriseDao.putEnterprise(enterprise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterpriseJlr getById(String id) {
|
||||
return enterpriseDao.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject expordata(HttpServletRequest request, String name, String abbrCode) {
|
||||
//声明一个集合用于存放供应商信息
|
||||
List listExcel = new ArrayList();
|
||||
StringBuffer hqlSb = new StringBuffer("from EnterpriseJlr where 1=1");
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
hqlSb.append(" and name like '%" + name.trim() + "%' ");
|
||||
}
|
||||
if (!TextUtils.isEmpty(abbrCode)) {
|
||||
hqlSb.append(" and abbr_code like '%" + abbrCode.trim() + "%'");
|
||||
}
|
||||
//声明一个json对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List list = null;
|
||||
try {
|
||||
//根据搜索条件获取供应商信息
|
||||
list = enterpriseDao.getRsByHql(hqlSb.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
jsonObject.put("result", "1");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出失败!");
|
||||
}
|
||||
if (list != null && list.size() > 0) {
|
||||
//声明一个excel表头
|
||||
EnterpriseExcelVO header = new EnterpriseExcelVO("VIN码", "经销商名称", "经销商代码", "地址",
|
||||
"24小时联系人1姓名", "24小时联系人1电话", "24小时联系人1职务", "24小时联系人2姓名", "24小时联系人2电话",
|
||||
"24小时联系人2职务", "对账联系人姓名", "对账联系人电话", "对账联系人职务", "邮箱", "服务类型", "车型", "首次销售日期");
|
||||
listExcel.add(header);
|
||||
//遍历供应商信息并将其放入供应商对象中
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
EnterpriseExcelVO enterpriseExcelVO = new EnterpriseExcelVO();
|
||||
EnterpriseJlr enterpriseJlr = (EnterpriseJlr) list.get(i);
|
||||
enterpriseExcelVO.setVinCode(enterpriseJlr.getVin_code());
|
||||
enterpriseExcelVO.setName(enterpriseJlr.getName());
|
||||
enterpriseExcelVO.setAbbrCode(enterpriseJlr.getAbbr_code());
|
||||
enterpriseExcelVO.setAddress(enterpriseJlr.getAddress());
|
||||
enterpriseExcelVO.setContract(enterpriseJlr.getContact());
|
||||
enterpriseExcelVO.setJob1(enterpriseJlr.getJob1());
|
||||
enterpriseExcelVO.setPhone1(enterpriseJlr.getPhone1());
|
||||
enterpriseExcelVO.setContact2(enterpriseJlr.getContact2());
|
||||
enterpriseExcelVO.setPhone2(enterpriseJlr.getPhone2());
|
||||
enterpriseExcelVO.setJob2(enterpriseJlr.getJob2());
|
||||
enterpriseExcelVO.setContact3(enterpriseJlr.getContact3());
|
||||
enterpriseExcelVO.setJob3(enterpriseJlr.getJob3());
|
||||
enterpriseExcelVO.setPhone3(enterpriseJlr.getPhone3());
|
||||
enterpriseExcelVO.setBrands(enterpriseJlr.getBrands());
|
||||
enterpriseExcelVO.setServiceQualification(enterpriseJlr.getService_qualification());
|
||||
enterpriseExcelVO.setFirstSaleDate(enterpriseJlr.getFirst_sale_date());
|
||||
enterpriseExcelVO.setCarType(enterpriseJlr.getCar_type());
|
||||
listExcel.add(enterpriseExcelVO);
|
||||
}
|
||||
//格式转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dateTime = simpleDateFormat.format(new Date());
|
||||
//导出路径
|
||||
String path = request.getRealPath("attached") + File.separator + "enterprise_" + dateTime + ".xlsx";
|
||||
String webUrl = UtilTools.getWebAddress(request) + File.separator + "attached" + File.separator + "enterprise_" + dateTime + ".xlsx";
|
||||
// webUrl = URLEncoder.encode(webUrl, "UTF-8");
|
||||
//所有信息保存到excel表中并导出表格
|
||||
boolean b = new EnterpriseExcelVO().saveAll(listExcel, path);
|
||||
if (b) {
|
||||
jsonObject.put("result", "0");// 0:成功,1失败
|
||||
jsonObject.put("msg", "导出成功!");
|
||||
jsonObject.put("webUrl", webUrl);
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.OrderCheckDao;
|
||||
import com.zhongdao.jlr.business.service.OrderCheckService;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/***
|
||||
* 处理服务结算的业务
|
||||
*/
|
||||
@Service(value = "orderCheckServiceImpl")
|
||||
public class OrderCheckServiceImpl implements OrderCheckService{
|
||||
|
||||
@Autowired
|
||||
OrderCheckDao dao;
|
||||
|
||||
@Override
|
||||
public Vo list(HttpServletRequest request, int page, int raws, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state) {
|
||||
return dao.list(request,page,raws,orderCode,queryDate1,rescueCompanyName,queryDate2,check_state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo lists(HttpServletRequest request, int page, int raws, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state,String state) {
|
||||
return dao.lists(request,page,raws,code,orderCode,queryDate1,rescueCompanyName,queryDate2,check_state,state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject exportData(HttpServletRequest request, String code, String orderCode, String queryDate1, String rescueCompanyName, String queryDate2, String check_state) {
|
||||
return dao.exportData(request,code,orderCode,queryDate1,rescueCompanyName,queryDate2,check_state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(String uid, String totalFee) {
|
||||
return dao.updateInfo(uid,totalFee);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.RoleDao;
|
||||
import com.zhongdao.jlr.business.service.RoleService;
|
||||
import com.zhongdao.jlr.business.vo.JLRMenu;
|
||||
import com.zhongdao.jlr.pojo.BaseMenu;
|
||||
import com.zhongdao.jlr.pojo.JLRAuthority;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 处理关于角色的业务
|
||||
*/
|
||||
@Service(value = "roleServiceImpl")
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Autowired
|
||||
RoleDao dao;
|
||||
// @Autowired
|
||||
// private SessionFactory sessionFactory;
|
||||
|
||||
@Override
|
||||
public Vo getRoleInfo(HttpServletRequest request, String name) {
|
||||
return dao.getRoleInfo(request,name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JLRMenu> getTreeInfo() {
|
||||
return dao.getTreeInfo();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean updateRoleInfo(JLRRole jlrRole, int[] ids) {
|
||||
// //获取当前日期
|
||||
// Date date=new Date();
|
||||
// jlrRole.setUpdate_time(date);
|
||||
// jlrRole.setDelete_flag(0);
|
||||
// //声明一个角色权限对象
|
||||
// JLRAuthority jlrAuthority=new JLRAuthority();
|
||||
// if(jlrRole.getId() == null){
|
||||
// //随机生成主键id
|
||||
// int id=Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3));
|
||||
// jlrRole.setId(id);
|
||||
// //将角色id放入对象中
|
||||
// jlrAuthority.setRole_id(id);
|
||||
// }else{
|
||||
// //如果角色id不为空则判断此操作为修改,删除权限信息
|
||||
// dao.deleteSupplier(jlrRole.getId());
|
||||
// jlrAuthority.setRole_id(jlrRole.getId());
|
||||
// }
|
||||
// //添加角色信息
|
||||
// dao.updateRoleInfo(jlrRole);
|
||||
// //将时间放入对象中
|
||||
// jlrAuthority.setUpdate_time(date);
|
||||
// try {
|
||||
// Session session = sessionFactory.getCurrentSession().getSessionFactory().openSession();
|
||||
// Transaction tx = session.beginTransaction();
|
||||
// //遍历菜单id,并批量添加数据
|
||||
// for(int i=0 ; i<ids.length;i++){
|
||||
// //将菜单id放入对象中
|
||||
// jlrAuthority.setMenu_id(ids[i]);
|
||||
// //将时间放入对象中
|
||||
// jlrAuthority.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
// //添加
|
||||
// System.out.println(i);
|
||||
// session.saveOrUpdate(jlrAuthority);
|
||||
// System.out.println(i+"---");
|
||||
// if (i % 2 == 0)
|
||||
//
|
||||
// {
|
||||
// session.flush();
|
||||
//
|
||||
// session.clear();
|
||||
//
|
||||
// tx.commit();
|
||||
//
|
||||
// tx = session.beginTransaction();
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// tx.commit();
|
||||
// closeResouce(session);
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 关闭资源
|
||||
// *
|
||||
// * @param object
|
||||
// * @throws Exception
|
||||
// */
|
||||
// protected void closeResouce(Object object) throws Exception {
|
||||
// if (null == object)
|
||||
// return;
|
||||
//
|
||||
// if (object instanceof Connection) {
|
||||
// Connection conn = (Connection) object;
|
||||
// conn.close();
|
||||
// } else if (object instanceof Statement) {
|
||||
// Statement statement = (Statement) object;
|
||||
// statement.close();
|
||||
// } else if (object instanceof PreparedStatement) {
|
||||
// PreparedStatement prepared = (PreparedStatement) object;
|
||||
// prepared.close();
|
||||
// } else if (object instanceof ResultSet) {
|
||||
// ResultSet rs = (ResultSet) object;
|
||||
// rs.close();
|
||||
// } else if (object instanceof Session) {
|
||||
// Session session = (Session) object;
|
||||
// session.close();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateRoleInfo(JLRRole jlrRole, int[] ids) {
|
||||
//获取当前日期
|
||||
Date date=new Date();
|
||||
jlrRole.setUpdate_time(date);
|
||||
jlrRole.setDelete_flag(0);
|
||||
//声明一个角色权限对象
|
||||
JLRAuthority jlrAuthority=new JLRAuthority();
|
||||
if(jlrRole.getId() == null){
|
||||
//随机生成主键id
|
||||
int id=Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3));
|
||||
jlrRole.setId(id);
|
||||
//将角色id放入对象中
|
||||
jlrAuthority.setRole_id(id);
|
||||
}else{
|
||||
//如果角色id不为空则判断此操作为修改,删除权限信息
|
||||
dao.deleteSupplier(jlrRole.getId());
|
||||
jlrAuthority.setRole_id(jlrRole.getId());
|
||||
}
|
||||
//添加角色信息
|
||||
dao.updateRoleInfo(jlrRole);
|
||||
//将时间放入对象中
|
||||
jlrAuthority.setUpdate_time(date);
|
||||
//遍历菜单id,并批量添加数据
|
||||
for(int i=0 ; i<ids.length;i++){
|
||||
//将菜单id放入对象中
|
||||
jlrAuthority.setMenu_id(ids[i]);
|
||||
//将时间放入对象中
|
||||
jlrAuthority.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
//添加
|
||||
boolean state=dao.updateRolesInfo(jlrAuthority);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JLRRole getRole(String id) {
|
||||
return dao.getUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMenu> getMenu(String id) {
|
||||
return dao.getMenu(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteRole(String id, String name) {
|
||||
//声明一个角色对象
|
||||
JLRRole jlrRole = new JLRRole();
|
||||
//将数据放入对象中
|
||||
jlrRole.setId(Integer.valueOf(id));
|
||||
jlrRole.setName(name);
|
||||
jlrRole.setDelete_flag(1);
|
||||
Date date = new Date();
|
||||
jlrRole.setUpdate_time(date);
|
||||
//分别删除角色信息和权限信息
|
||||
if (dao.updateRoleInfo(jlrRole) && dao.deleteSupplier(jlrRole.getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.SupplierDao;
|
||||
import com.zhongdao.jlr.business.service.SupplierService;
|
||||
import com.zhongdao.jlr.business.vo.Contract;
|
||||
import com.zhongdao.jlr.business.vo.Destination;
|
||||
import com.zhongdao.jlr.business.vo.Enterprise;
|
||||
import com.zhongdao.jlr.pojo.JLRDestination;
|
||||
import com.zhongdao.jlr.pojo.JLRSupplier;
|
||||
import com.zhongdao.jlr.pojo.JLRUserContract;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service(value = "supplierServiceImpl")
|
||||
public class SupplierServiceImpl implements SupplierService {
|
||||
|
||||
@Autowired
|
||||
SupplierDao dao;
|
||||
@Override
|
||||
public Vo getContractInfo(HttpServletRequest request,String name,String id) {
|
||||
return dao.getContractInfo(request,name,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Contract> getAssignContract(String id) {
|
||||
return dao.getAssignContract(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Destination> geAssignDestination(String id) {
|
||||
return dao.getAssignDestination(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enterprise> geAssignEnterprise(String id) {
|
||||
return dao.getAssignEnterprise(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getEnterpriseInfo(HttpServletRequest request,String name,String id) {
|
||||
return dao.getEnterpriseInfo(request,name,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getDestination(HttpServletRequest request, String name,String id) {
|
||||
return dao.getDestination(request,name,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertContractInfo(Integer id, int[] ids) {
|
||||
//声明一个合同对象
|
||||
JLRUserContract jlrUserContract=new JLRUserContract();
|
||||
jlrUserContract.setJlr_user_id(id);
|
||||
//批量插入数据
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
jlrUserContract.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
jlrUserContract.setContract_id(ids[i]);
|
||||
boolean state=dao.insertContractInfo(jlrUserContract);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean insertDestinationInfo(Integer id, int[] ids) {
|
||||
//声明一个合同对象
|
||||
JLRDestination jlrDestination=new JLRDestination();
|
||||
jlrDestination.setJlr_user_id(id);
|
||||
//批量插入数据
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
jlrDestination.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
jlrDestination.setContract_destination_id(ids[i]);
|
||||
boolean state=dao.insertDestinationInfo(jlrDestination);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertEnterpriseInfo(Integer id, int[] ids) {
|
||||
//声明一个合同对象
|
||||
JLRSupplier jlrSupplier=new JLRSupplier();
|
||||
jlrSupplier.setJlr_user_id(id);
|
||||
//批量插入数据
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
jlrSupplier.setId(Integer.valueOf((System.currentTimeMillis() / 10 + "").substring(3)));
|
||||
jlrSupplier.setSupplier_id(ids[i]);
|
||||
boolean state=dao.insertEnterpriseInfo(jlrSupplier);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteEnterpriseInfo(Integer id, int[] ids) {
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
int sid=ids[i];
|
||||
boolean state=dao.deleteEnterpriseInfo(sid,id);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteContractInfo(Integer id, int[] ids) {
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
int cid=ids[i];
|
||||
boolean state=dao.deleteContractInfo(cid,id);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDestinationInfo(Integer id, int[] ids) {
|
||||
for(int i=0;i<ids.length;i++) {
|
||||
//将数据放入对象里
|
||||
int did=ids[i];
|
||||
boolean state=dao.deleteDestinationInfo(did,id);
|
||||
if(state == false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JLRUserContract> getDestinationInfo(String id) {
|
||||
return dao.getContract(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.zhongdao.jlr.business.service.impl;
|
||||
|
||||
import com.util.Vo;
|
||||
import com.zhongdao.jlr.business.dao.UserInfoDao;
|
||||
import com.zhongdao.jlr.business.service.UserInfoService;
|
||||
import com.zhongdao.jlr.pojo.BaseRole;
|
||||
import com.zhongdao.jlr.pojo.EnterpriseJlr;
|
||||
import com.zhongdao.jlr.pojo.JLRRole;
|
||||
import com.zhongdao.jlr.pojo.JLRUser;
|
||||
import jodd.util.BCrypt;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 处理用户信息管理的业务
|
||||
*/
|
||||
@Service(value = "userInfoService")
|
||||
public class UserInfoServiceImpl implements UserInfoService {
|
||||
|
||||
@Autowired
|
||||
UserInfoDao dao;
|
||||
|
||||
@Override
|
||||
public List<JLRRole> getRoleInfo() {
|
||||
return dao.getRoleInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseJlr> getEnterpriseInfo() {
|
||||
return dao.getEnterpriseInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vo getUserInfo(HttpServletRequest request,String name,String phone,String role,String username) {
|
||||
return dao.getUserInfo(request,name,phone,role,username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateUserInfo(JLRUser user) {
|
||||
//声明一个当前日期的对象
|
||||
Date date=new Date();
|
||||
//将当前日期存入对象中
|
||||
user.setUpdate_time(date);
|
||||
if(!TextUtils.isEmpty(user.getPassword())){
|
||||
//密码加密
|
||||
user.setPassword(BCrypt.hashpw(user.getPassword(),BCrypt.gensalt()));
|
||||
}
|
||||
return dao.updateUserInfo(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JLRUser getUser(String id) {
|
||||
return dao.getUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUser(JLRUser user) {
|
||||
return dao.deleteUser(user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.zhongdao.jlr.business.servlet;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
/**
|
||||
* 用于
|
||||
*/
|
||||
public class ReceiveCustomerInfoServlet extends HttpServlet {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.zhongdao.jlr.business.vo;
|
||||
|
||||
import com.ljh.excel.annotation.ColumnAnnotation;
|
||||
import com.ljh.excel.bean.BaseBean;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ConsumeQueryExcelVO extends BaseBean {
|
||||
|
||||
@ColumnAnnotation("A")
|
||||
private String vinCode;//VIN码
|
||||
@ColumnAnnotation("B")
|
||||
private String electronicccounts;//电子账户
|
||||
@ColumnAnnotation("C")
|
||||
private String userPhone;//手机号码
|
||||
@ColumnAnnotation("D")
|
||||
private String license;//车牌号
|
||||
@ColumnAnnotation("E")
|
||||
private String consumeTime;// 消费时间
|
||||
@ColumnAnnotation("F")
|
||||
private String consumeCount;// 消费金额
|
||||
@ColumnAnnotation("G")
|
||||
private String name;//经销商
|
||||
@ColumnAnnotation("H")
|
||||
private String state;//审批状态
|
||||
|
||||
public ConsumeQueryExcelVO(String vinCode, String electronicccounts, String userPhone, String license, String consumeTime, String consumeCount, String name, String state) {
|
||||
this.vinCode = vinCode;
|
||||
this.electronicccounts = electronicccounts;
|
||||
this.userPhone = userPhone;
|
||||
this.license = license;
|
||||
this.consumeTime = consumeTime;
|
||||
this.consumeCount = consumeCount;
|
||||
this.name = name;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public ConsumeQueryExcelVO() {
|
||||
}
|
||||
|
||||
public String getVinCode() {
|
||||
return vinCode;
|
||||
}
|
||||
|
||||
public void setVinCode(String vinCode) {
|
||||
this.vinCode = vinCode;
|
||||
}
|
||||
|
||||
public String getElectronicccounts() {
|
||||
return electronicccounts;
|
||||
}
|
||||
|
||||
public void setElectronicccounts(String electronicccounts) {
|
||||
this.electronicccounts = electronicccounts;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone;
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public String getConsumeTime() {
|
||||
return consumeTime;
|
||||
}
|
||||
|
||||
public void setConsumeTime(String consumeTime) {
|
||||
this.consumeTime = consumeTime;
|
||||
}
|
||||
|
||||
public String getConsumeCount() {
|
||||
return consumeCount;
|
||||
}
|
||||
|
||||
public void setConsumeCount(String consumeCount) {
|
||||
this.consumeCount = consumeCount;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user