Browse Source

reconstruct

ylx 7 years ago
parent
commit
db49f71972

+ 4 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/OperationHistoryDao.java

@@ -22,4 +22,8 @@ public class OperationHistoryDao {
 	public int findAllInformation(){
 		return dao.findAllInformation();
 	}
+
+	public List<OperationHistory> queryOperationHistoryInformationByUser(Map<String, Object> map) {
+		return dao.queryOperationHistoryInformationByUser(map);
+	}
 }

+ 11 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/UserAuthoricationDao.java

@@ -5,6 +5,7 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.mapperInterface.UserAuthoricationMapper;
 
 /**
@@ -27,4 +28,14 @@ public class UserAuthoricationDao {
 	public List<String> queryUserPermissionNames(int userId){
 		return userAuthoricationMapper.queryUserPermissionNames(userId);
 	}
+	
+	//根据用户的id号查询用户的账号名Account名
+	public String queryUserAccount(int userId) {
+		return userAuthoricationMapper.queryUserAccount(userId);
+	}
+	
+	//根据id号查询用户全部的信息
+	public UserDetail queryUserDetailInformation(int userId) {
+		return userAuthoricationMapper.queryUserDetailInformation(userId);
+	}
 }

+ 91 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/entity/UserDetail.java

@@ -0,0 +1,91 @@
+package com.fuzamei.entity;
+
+import java.util.List;
+
+public class UserDetail {
+	private Integer id;							//用户表主键
+	private Integer user_id;					//用户id
+	private String account;						//用户账号名称
+	private String password;					//用户密码
+	private String random;						//随机数
+	private String public_key;					//公钥
+	private String private_key;					//私钥
+	private String organization_name;			//机构名称
+	private String person_name;					//人员名称
+	private List<String> role_name;				//角色名称
+	private List<String> authority_name;		//权限名称
+	public Integer getId() {
+		return id;
+	}
+	public void setId(Integer id) {
+		this.id = id;
+	}
+	public Integer getUser_id() {
+		return user_id;
+	}
+	public void setUser_id(Integer user_id) {
+		this.user_id = user_id;
+	}
+	public String getAccount() {
+		return account;
+	}
+	public void setAccount(String account) {
+		this.account = account;
+	}
+	public String getPassword() {
+		return password;
+	}
+	public void setPassword(String password) {
+		this.password = password;
+	}
+	public String getRandom() {
+		return random;
+	}
+	public void setRandom(String random) {
+		this.random = random;
+	}
+	public String getPublic_key() {
+		return public_key;
+	}
+	public void setPublic_key(String public_key) {
+		this.public_key = public_key;
+	}
+	public String getPrivate_key() {
+		return private_key;
+	}
+	public void setPrivate_key(String private_key) {
+		this.private_key = private_key;
+	}
+	public String getOrganization_name() {
+		return organization_name;
+	}
+	public void setOrganization_name(String organization_name) {
+		this.organization_name = organization_name;
+	}
+	public String getPerson_name() {
+		return person_name;
+	}
+	public void setPerson_name(String person_name) {
+		this.person_name = person_name;
+	}
+	public List<String> getRole_name() {
+		return role_name;
+	}
+	public void setRole_name(List<String> role_name) {
+		this.role_name = role_name;
+	}
+	public List<String> getAuthority_name() {
+		return authority_name;
+	}
+	public void setAuthority_name(List<String> authority_name) {
+		this.authority_name = authority_name;
+	}
+	@Override
+	public String toString() {
+		return "UserDetail [id=" + id + ", user_id=" + user_id + ", account=" + account + ", password=" + password
+				+ ", random=" + random + ", public_key=" + public_key + ", private_key=" + private_key
+				+ ", organization_name=" + organization_name + ", person_name=" + person_name + ", role_name="
+				+ role_name + ", authority_name=" + authority_name + "]";
+	}
+	
+}

+ 47 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/OperationHistoryMapper.xml

@@ -43,4 +43,51 @@
 		select count(*) from operation_history
 	</select>
 	
+	<!-- 根据操作记录给的条件查询分页数据,但是还要根据用户的账号名来查询 -->
+	<select id="queryOperationHistoryInformationByUser" resultType="com.fuzamei.entity.OperationHistory">
+		select
+			temp.id,
+			temp.operator_type_id,
+			temp.operator_name,
+			temp.operator_account,
+			temp.operator_role,
+			temp.operator_person,
+			temp.operator_time,
+			temp.hash
+		from
+			(select 
+				oh.id,
+				oh.operator_type_id,
+				ot.operator_name,
+				oh.operator_account,
+				oh.operator_role,
+				oh.operator_person,
+				oh.operator_time,
+				oh.hash
+			from 
+				operation_history oh 
+			left join 
+				operation_type ot 
+			on 
+				oh.operator_type_id=ot.operator_type_id 
+			<where>
+				<if test="account!='' and account!=null">
+					oh.operator_account=#{account} 
+				</if>
+				<if test="role!='' and role!=null">
+					and oh.operator_role=#{role} 
+				</if>
+				<if test="type!='' and type!=null">
+					and ot.operator_name=#{type}
+				</if>
+				<if test="startTime!=null and endTime!=null">
+					and oh.operator_time between #{startTime} and #{endTime}
+				</if>
+			</where>
+			order by oh.id asc  
+			limit #{startPage},#{rowNum}) temp
+		where 
+			operator_account=#{Account}
+	</select>
+	
 </mapper>

+ 104 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/UserAuthoricationMapper.xml

@@ -57,4 +57,108 @@
 			temp.authority_id=t_permission.authority_id
 	</select>
 	
+	<!-- 根据用户的id号查询用户的账号名Account名 -->
+	<select id="queryUserAccount" resultType="string">
+		select account from t_user where user_id=#{userId};
+	</select>
+	
+	<!-- 查询出一个userId号下的用户所有详细信息包括基本信息,还有角色,权限信息 -->
+	<select id="queryUserDetailInformation" resultMap="UserDetailRM">
+		select 
+			temp.id,
+			temp.user_id,
+			temp.account,
+			temp.password,
+			temp.random,
+			temp.public_key,
+			temp.private_key,
+			temp.organization_name,
+			temp.person_name,
+			temp.role_name,
+			t_permission.authority_name
+		from 
+			(select 
+				temp.id,
+				temp.user_id,
+				temp.account,
+				temp.password,
+				temp.random,
+				temp.public_key,
+				temp.private_key,
+				temp.organization_name,
+				temp.person_name,
+				temp.role_id,
+				temp.role_name,
+				role_permission.authority_id
+			from
+				(select 
+					temp.id,
+					temp.user_id,
+					temp.account,
+					temp.password,
+					temp.random,
+					temp.public_key,
+					temp.private_key,
+					temp.organization_name,
+					temp.person_name,
+					temp.role_id,
+					t_role.role_name
+				from 
+					(select 
+						temp.id,
+						temp.user_id,
+						temp.account,
+						temp.password,
+						temp.random,
+						temp.public_key,
+						temp.private_key,
+						temp.organization_name,
+						temp.person_name,
+						user_role.role_id
+					from
+						(select 
+							id,
+							user_id,
+							account,
+							password,
+							random,
+							public_key,
+							private_key,
+							organization_name,
+							person_name
+						from 
+							t_user
+						where 
+							user_id=#{userId}) temp 
+					left join 
+						user_role
+					on 
+						temp.user_id=user_role.user_id) temp 
+				left join 
+					t_role
+				on 
+					temp.role_id=t_role.role_id) temp 
+			left join
+				role_permission
+			on 
+				temp.role_id=role_permission.role_id) temp
+		left join 
+			t_permission
+		on 
+			temp.authority_id=t_permission.authority_id
+	</select>
+	<!-- 专门针对queryUserDetailInformation返回值结果用的 -->
+	<resultMap type="com.fuzamei.entity.UserDetail" id="UserDetailRM" autoMapping="true">
+		<id column="id" property="id"/>
+		<collection property="role_name" ofType="java.lang.String" javaType="java.util.ArrayList">
+			<constructor>
+				<arg column="role_name"/>
+			</constructor>
+		</collection>
+		<collection property="authority_name" ofType="java.lang.String" javaType="java.util.ArrayList">
+			<constructor>
+				<arg column="authority_name"/>
+			</constructor>
+		</collection>
+	</resultMap>
 </mapper>

+ 2 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/OperationHistoryMapper.java

@@ -10,4 +10,6 @@ public interface OperationHistoryMapper {
 	int findAllInformation();
 	
 	List<OperationHistory> queryOperationHistoryInformation(Map<String, Object> map);
+
+	List<OperationHistory> queryOperationHistoryInformationByUser(Map<String, Object> map);
 }

+ 6 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/UserAuthoricationMapper.java

@@ -2,11 +2,17 @@ package com.fuzamei.mapperInterface;
 
 import java.util.List;
 
+import com.fuzamei.entity.UserDetail;
+
 public interface UserAuthoricationMapper {
 
 	List<String> queryUserRolenames(int userId);//根据用户的id号查询用户的角色信息
 
 	List<String> queryUserPermissionNames(int userId);//根据用户的id号查询用户的权限信息
+
+	String queryUserAccount(int userId);//根据用户的id号查询用户的账号名Account名
+
+	UserDetail queryUserDetailInformation(int userId);//根据用户的id号查询用户的账号所有信息
 	
 	
 }

+ 59 - 74
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/OperationHistoryService.java

@@ -8,10 +8,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.fuzamei.dao.OperationHistoryDao;
+import com.fuzamei.dao.UserAuthoricationDao;
 import com.fuzamei.entity.OperationHistory;
 import com.fuzamei.entity.OperationHistoryBO;
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.utils.DateUtil;
 import com.fuzamei.utils.PageDTO;
+import com.fuzamei.utils.StringUtil;
 
 @Service
 public class OperationHistoryService {
@@ -19,90 +22,50 @@ public class OperationHistoryService {
 	@Autowired
 	private OperationHistoryDao operationHistoryDao;
 
-	private static final int ROW_NUM = 10; // 分页每页显示数据的数量
+	@Autowired
+	private UserAuthoricationDao userAuthoricationDao;
 
 	/**
 	 * 
-	 * @Title: queryOperationHistoryInformation @Description:
-	 * TODO(从dao层查询出分页数据信息) @param @param page @param @param
-	 * account @param @param role @param @param type @param @param
-	 * startTime @param @param endTime @param @return 设定文件 @return PageDTO
-	 * 返回类型 @author ylx @date 2017年12月14日 下午8:09:43 @throws
+	* @Title: queryOperationHistoryInformation
+	* @Description: TODO(根据用户的id号查询操作记录,但是现在只做了风管岗可以查看所有的信息,)
+	* @param @param map
+	* @param @return    设定文件
+	* @return PageDTO    返回类型
+	* @author ylx
+	* @date 2017年12月27日 下午3:02:42
+	* @throws
 	 */
-/*	public PageDTO queryOperationHistoryInformation(Map<String, Object> map) {
-		int page = 1; // 默认页是第一页
-		String account = ""; // 账号默认空值
-		String role = ""; // 操作角色默认空值
-		String type = ""; // 操作类型默认空值
-		long startTime = 0; // 开始时间默认0
-		long endTime = Long.MAX_VALUE; // 结束时间默认Long最大值
-		if (!"".equals(map.get("page")) && map.get("page") != null) { 							// 等于空就直接取第一页
-			try {
-				page = Integer.parseInt((String) map.get("page"));
-				if (page < 1) {
-					page = 1;
-				}
-			} catch (Exception e) {
-				page = 1; // 数据解析异常page还是1
-			}
-		}
-		if (!"".equals(map.get("account")) && map.get("account") != null) { 						// 等于空就直接取空值
-			try {
-				account = (String) map.get("account");
-			} catch (Exception e) {
-				account="";
-			}
-		}
-		if (!"".equals(map.get("role")) && map.get("role") != null) { // 等于空就直接取空值
-			try {
-				role = (String) map.get("role");
-			} catch (Exception e) {
-				role="";
-			}
-		}
-		if (!"".equals(map.get("type")) && map.get("type") != null) { // 等于空就直接取空值
-			try {
-				type = (String) map.get("type");
-			} catch (Exception e) {
-				type="";
-			}
-		}
-		if (!"".equals(map.get("startTime")) && map.get("startTime") != null) { // 等于空就直接取空值
-			try {
-				startTime = Long.parseLong((String) map.get("startTime"));
-			} catch (Exception e) {
-				startTime = 0; // 数据解析异常或转换类型异常startTime还是0
-			}
+	public PageDTO queryOperationHistoryInformation(Map<String, Object> map) {
+		PageDTO pageDto = new PageDTO(); // 创建分页对象
+		//定义一个查询信息的list
+		List<OperationHistory> informationList=null;
+		int userId = (Integer) map.get("userId");
+		UserDetail userDetail=userAuthoricationDao.queryUserDetailInformation(userId);
+		if(userDetail==null){
+			throw new RuntimeException("用户信息不存在");
 		}
-		if (!"".equals(map.get("endTime")) && map.get("endTime") != null) { // 等于空就直接取空值
-			try {
-				endTime = Long.parseLong((String) map.get("endTime"));
-			} catch (Exception e) {
-				endTime = Long.MAX_VALUE; // 数据解析异常或转换类型异常endTime还是9223372036854775807L
+		List<String> roleList = userDetail.getRole_name();
+		if(roleList.contains("风管岗")){
+			// 去dao层取分页的数据,因为是风管岗位,可以查看所有人的操作记录
+			informationList = operationHistoryDao.queryOperationHistoryInformation(map); 
+		}else{
+			//根据用户id号查询出用户的账号account信息
+			//TODO这里还有上下级关系查看的问题还没解决============================================================>>>>>>待定
+			String account = userDetail.getAccount();
+			if(StringUtil.isEmpty(account)){
+				throw new RuntimeException("用户账号信息不存在");
 			}
+			map.put("Account", account);
+			informationList = operationHistoryDao.queryOperationHistoryInformationByUser(map); 
 		}
-		PageDTO pageDto = new PageDTO(); // 创建分页对象
-		Map<String, Object> mapToDao = new LinkedHashMap<String, Object>();
-		mapToDao.put("startPage", (page - 1) * ROW_NUM);
-		mapToDao.put("account", account);
-		mapToDao.put("role", role);
-		mapToDao.put("type", type);
-		if (startTime <= endTime) {
-			mapToDao.put("startTime", startTime);
-			mapToDao.put("endTime", endTime);
-		} else {
-			mapToDao.put("startTime", startTime);
-			mapToDao.put("endTime", Long.MAX_VALUE);
-		}
-		mapToDao.put("rowNum", ROW_NUM); //默认每页显示数据是10条,可根据需求修改分页数量
-
-		List<OperationHistory> informationList = operationHistoryDao.queryOperationHistoryInformation(mapToDao); // 去dao层取分页的数据
-
 		int count = operationHistoryDao.findAllInformation();
 		pageDto.setTotal(count);
 		pageDto.setRows(informationList);
 		return pageDto;
-	}*/
+	}
+
+	
 
 	/**
 	 * 
@@ -115,7 +78,7 @@ public class OperationHistoryService {
 	* @date 2017年12月26日 下午4:26:44
 	* @throws
 	 */
-	public PageDTO queryOperationHistoryInformation(OperationHistoryBO operationHistoryBO) {
+	/*public PageDTO queryOperationHistoryInformation(OperationHistoryBO operationHistoryBO) {
 		Integer userId = operationHistoryBO.getUserId();
 		Integer page = operationHistoryBO.getPage();
 		String account = operationHistoryBO.getAccount();
@@ -137,6 +100,28 @@ public class OperationHistoryService {
 		pageDto.setTotal(count);
 		pageDto.setRows(informationList);
 		return pageDto;
+	}*/
+	
+	/*//定义一个查询信息的list
+	List<OperationHistory> informationList=null;
+	int userId = (Integer) map.get("userId");
+	//查询用户的角色信息
+	List<String> roleList = userAuthoricationDao.queryUserRoleNames(userId);
+	//如果没有角色信息直接抛出异常信息
+	if(roleList==null||roleList.size()==0){
+		throw new RuntimeException("用户角色信息不存在");
 	}
+	if(roleList.contains("风管岗")){
+		// 去dao层取分页的数据,因为是风管岗位,可以查看所有人的操作记录
+		informationList = operationHistoryDao.queryOperationHistoryInformation(map); 
+	}else{
+		//根据用户id号查询出用户的账号account信息
+		String account = userAuthoricationDao.queryUserAccount(userId);
+		if(StringUtil.isEmpty(account)){
+			throw new RuntimeException("用户信息不存在");
+		}
+		map.put("Account", account);
+		informationList = operationHistoryDao.queryOperationHistoryInformationByUser(map); 
+	}*/
 
 }

+ 65 - 137
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/ProjectFileService.java

@@ -12,7 +12,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.fuzamei.dao.ProjectFileDao;
+import com.fuzamei.dao.UserAuthoricationDao;
 import com.fuzamei.entity.ProjectFile;
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.utils.PageDTO;
 
 @Service
@@ -20,13 +22,14 @@ public class ProjectFileService {
 
 	@Autowired
 	private ProjectFileDao projectFileDao;
-
-	private static final int ROW_NUM = 10; // 分页每页显示数据的数量(固定10条数据)
+	
+	@Autowired
+	private UserAuthoricationDao userAuthoricationDao;
 
 	/**
 	 * 
 	* @Title: queryProjectFileInformation
-	* @Description: TODO(这里用一句话描述这个方法的作用)
+	* @Description: TODO(查询项目文档的信息)
 	* @param @param map
 	* @param @return    设定文件
 	* @return PageDTO    返回类型
@@ -35,55 +38,11 @@ public class ProjectFileService {
 	* @throws
 	 */
 	public PageDTO queryProjectFileInformation(Map<String, Object> map) {
-		int page = 1; // 默认页数是第一页
-		String projectName = ""; // 默认名称为空值
-		long startTime = 0; // 默认起始时间为0
-		long endTime = Long.MAX_VALUE; // 默认终止时间为Long最大值
-		if (!"".equals(map.get("page")) && map.get("page") != null) { // 等于空就直接取第一页
-			try {
-				page = Integer.parseInt((String) map.get("page"));
-				if (page < 1) {
-					page = 1;
-				}
-			} catch (Exception e) {
-				page = 1; // 数据解析异常或者类型转换异常page还是1
-			}
-		}
-		if (!"".equals(map.get("projectName")) && map.get("projectName") != null) { // 等于空就直接取空值
-			try {
-				projectName = (String) map.get("projectName");
-			} catch (Exception e) {
-				projectName="";
-			}
-		}
-		if (!"".equals(map.get("startTime")) && map.get("startTime") != null) { // 等于空就直接取空值
-			try {
-				startTime = Long.parseLong((String) map.get("startTime"));
-			} catch (Exception e) {
-				startTime = 0; // 数据解析异常和类型转换异常startTime还是0
-			}
-		}
-		if (!"".equals(map.get("endTime")) && map.get("endTime") != null) { // 等于空就直接取空值
-			try {
-				endTime = Long.parseLong((String) map.get("endTime"));
-			} catch (Exception e) {
-				endTime = Long.MAX_VALUE; // 数据解析异常和类型转换异常endTime还是9223372036854775807L
-			}
-		}
-
+		
 		PageDTO pageDto = new PageDTO(); // 创建分页对象
-		Map<String, Object> mapToDao = new LinkedHashMap<String, Object>();
-		mapToDao.put("startPage", (page - 1) * ROW_NUM);
-		mapToDao.put("projectName", projectName);
-		if (startTime <= endTime) {
-			mapToDao.put("startTime", startTime);
-			mapToDao.put("endTime", endTime);
-		} else {
-			mapToDao.put("startTime", startTime);
-			mapToDao.put("endTime", Long.MAX_VALUE);
-		}
-		mapToDao.put("rowNum", ROW_NUM); // 默认每页显示数据是10条,可根据需求修改分页数量
-		List<ProjectFile> informationList = projectFileDao.queryProjectFileInformation(mapToDao);
+		int userId = (Integer) map.get("userId");
+		checkUserAuthority(userId,"监管机构","省分行托管分中心档案保管岗");		//查看用户非空和权限
+		List<ProjectFile> informationList = projectFileDao.queryProjectFileInformation(map);
 		int count = projectFileDao.findAllInformation();
 		pageDto.setRows(informationList);
 		pageDto.setTotal(count);
@@ -103,36 +62,13 @@ public class ProjectFileService {
 	* @throws
 	 */
 	public Map<String, Object> checkoutProjectFiles(Map<String, Object> map) {
-		Integer projectId = null;	//默认项目编号为空
-		String projectName="";		//默认项目名称为空值
-		if(!"".equals(map.get("projectId")) && null!=map.get("projectId")){
-			try {
-				projectId = Integer.parseInt((String)map.get("projectId"));
-			} catch (Exception e) {
-				projectId = null;	//如果解析出现异常或者类型转换异常,依然保持projectId为null
-			}
-		}
-		if (!"".equals(map.get("projectName")) && map.get("projectName") != null) { // 等于空就直接取空值
-			try {
-				projectName = (String) map.get("projectName");
-			} catch (Exception e) {
-				projectName="";
-			}
-		}
-		
-		Map<String, Object> mapToDao = new LinkedHashMap<String, Object>();
-		
-		mapToDao.put("projectId", projectId);
-		mapToDao.put("projectName", projectName);
-		
-		List<ProjectFile> informationList = projectFileDao.checkoutProjectFiles(mapToDao);	//将项目id和项目名称封装成map到dao层去获取数据
-		
+		int userId = (Integer) map.get("userId");
+		checkUserAuthority(userId,"监管机构","省分行托管分中心档案保管岗");	//查看用户非空和权限
+		List<ProjectFile> informationList = projectFileDao.checkoutProjectFiles(map);	//将项目id和项目名称封装成map到dao层去获取数据
 		Map<String, Object> mapBackToController = new LinkedHashMap<String, Object>();
-		
-		mapBackToController.put("projectId", projectId);
-		mapBackToController.put("projectName", projectName);
-		mapBackToController.put("fileInformations", informationList);
-		
+		mapBackToController.put("projectId", map.get("projectId"));		//展示给前端的项目id号码
+		mapBackToController.put("projectName", map.get("projectName"));	//展示给前端的项目名称
+		mapBackToController.put("fileInformations", informationList);	//展示给前端的所有文件信息(包括文件名、文件hash值,还有文件url下载地址)
 		return mapBackToController;
 	}
 
@@ -148,76 +84,68 @@ public class ProjectFileService {
 	 */
 	@Transactional(rollbackFor=Exception.class)
 	public void insertInformationIntoTable(Map<String, Object> map) {
-		String projectId="";			//项目id号
-		String projectName="";			//项目文件名称
-		String url="";					//url路径名称
-		String attachmentName="";		//附件名称
-		if (!"".equals(map.get("projectId")) && map.get("projectId") != null) { // 等于空就直接取空值
-			try {
-				projectId = (String) map.get("projectName");
-			} catch (Exception e) {
-				throw new RuntimeException("projectId类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("项目id号为空");
-		}
-		if (!"".equals(map.get("projectName")) && map.get("projectName") != null) { // 等于空就直接取空值
-			try {
-				projectName = (String) map.get("projectName");
-			} catch (Exception e) {
-				throw new RuntimeException("projectName类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("项目名称为空");
-		}
-		if (!"".equals(map.get("url")) && map.get("url") != null) { // 等于空就直接取空值
-			try {
-				url = (String) map.get("url");
-			} catch (Exception e) {
-				throw new RuntimeException("url类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("url路径名称为空");
-		}
-		if (!"".equals(map.get("attachmentName")) && map.get("attachmentName") != null) { // 等于空就直接取空值
-			try {
-				attachmentName = (String) map.get("attachmentName");
-			} catch (Exception e) {
-				throw new RuntimeException("attachmentName类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("附件名称为空");
-		}
-		
+		long currentTime = System.currentTimeMillis();										//获取当前时间
+		int attachmentId = (Integer)(int)(Math.random()*1000000);							//附件id不能用随机数,这里到时候要改的================>>待定TODO
+		UserDetail userDetail = (UserDetail) map.get("userDetail");							//获取controller传过来的UserDetail对象
 		//将数据封装到mapToDaoForProjectFile,并插入【项目文档表】
 		Map<String, Object> mapToDaoForProjectFile = new LinkedHashMap<String,Object>();
-		mapToDaoForProjectFile.put("projectId", projectId);
-		mapToDaoForProjectFile.put("projectName", projectName);
-		mapToDaoForProjectFile.put("attachmentId", (Integer)(int)(Math.random()*1000000));		//附件id不能用随机数,这里到时候要改的。。。。。。。。。TODO
-		mapToDaoForProjectFile.put("updateTime", System.currentTimeMillis());			//上传文件的更新时间为当前时间
-		mapToDaoForProjectFile.put("hash", "to be changed");							//上传文件的hash值到时候要通过对文件进行计算后才能进行数据库的录入(这里先写死)。。。。。。。。TODO
-		projectFileDao.insertInformationIntoTable(mapToDaoForProjectFile);			//将以上的数据直接添加到数据库中【项目文档表】去
+		mapToDaoForProjectFile.put("projectId", map.get("projectId"));
+		mapToDaoForProjectFile.put("projectName", map.get("projectName"));
+		mapToDaoForProjectFile.put("attachmentId", attachmentId);							//附件id不能用随机数,这里到时候要改的================>>待定TODO
+		mapToDaoForProjectFile.put("updateTime", currentTime);								//上传文件的更新时间为当前时间
+		mapToDaoForProjectFile.put("hash", map.get("hash"));								//将算好的hash值放入mapToDaoForProjectFile中
+		projectFileDao.insertInformationIntoTable(mapToDaoForProjectFile);					//将以上的数据直接添加到数据库中【项目文档表】去
 		
 		//将数据封装到mapToDaoForAttachment,并插入【附件表】
 		Map<String, Object> mapToDaoForAttachment = new LinkedHashMap<String,Object>();
-		mapToDaoForAttachment.put("attachmentId", mapToDaoForProjectFile.get("attachmentId"));
-		mapToDaoForAttachment.put("attachmentName", attachmentName);					//附件名称需要录入
-		mapToDaoForAttachment.put("url", url);										//下载文件需要用到的url地址需要录入
-		mapToDaoForAttachment.put("userId", 2000000001);								//用户id(这里先写死)。。。。。。。。。。TODO
-		mapToDaoForAttachment.put("addTime", (Long)mapToDaoForProjectFile.get("updateTime"));		//这里添加的文件上传时间,和项目文档更新时间一样
+		mapToDaoForAttachment.put("attachmentId", attachmentId);							//附件id不能用随机数,这里到时候要改的================>>待定TODO
+		mapToDaoForAttachment.put("attachmentName", map.get("attachmentName"));				//附件名称需要录入
+		mapToDaoForAttachment.put("url", map.get("url"));									//下载文件需要用到的url地址需要录入
+		mapToDaoForAttachment.put("userId", userDetail.getUser_id());						//直接通过userDetail中获取
+		mapToDaoForAttachment.put("addTime", currentTime);									//这里添加的文件上传时间,和项目文档更新时间一样
 		projectFileDao.insertInformationToAttachment(mapToDaoForAttachment);
 		
 		//此外,还要将业务申报的这个操作信息插入到操作记录表中【操作记录表】
 		Map<String, Object> mapToOperationHistory = new LinkedHashMap<String,Object>();
 		mapToOperationHistory.put("operatorTypeId", 1011);								//上传项目文档的类型为1011
-		mapToOperationHistory.put("operatorAccount", 300000001);						//操作账号先定死
+		mapToOperationHistory.put("operatorAccount", userDetail.getAccount());			//操作账号通过userDetail中获取
 		mapToOperationHistory.put("operatorRole", "省分行托管分中心档案保管岗");			//创建这个操作的角色只能是省分行托管分中心档案保管岗
-		mapToOperationHistory.put("operatorPerson", "张三");								//操作人暂时先写死
-		mapToOperationHistory.put("operatorTime", (Long)mapToDaoForProjectFile.get("updateTime"));//操作时间为当前操作时间
-		mapToOperationHistory.put("hash", "to be calculated from operation");			//如何计算操作的hash值????
-		projectFileDao.insertOperationHistoryInformationToDao(mapToOperationHistory);//将操作记录信息插入到操作记录表中
+		mapToOperationHistory.put("operatorPerson", userDetail.getPerson_name());		//操作人通过userDetail中获取
+		mapToOperationHistory.put("operatorTime", currentTime);							//操作时间为当前操作时间
+		mapToOperationHistory.put("hash", map.get("hash"));								//如何计算操作的hash值?(按照上传的项目文件的hash值算)=====>>待定TODO
+		projectFileDao.insertOperationHistoryInformationToDao(mapToOperationHistory);   //将操作记录信息插入到操作记录表中
 		
 	}
+
+
+	/**
+	 * 
+	* @Title: checkUserAuthority
+	* @Description: TODO(查看用户是否有权限下载项目文档文件,如果没有权限直接抛出异常,校验结束返回一个UserDetail信息)
+	* @param @param userId    设定文件
+	* @return UserDetail    返回类型
+	* @author ylx
+	* @date 2017年12月27日 下午4:51:22
+	* @throws
+	 */
+	public UserDetail checkUserAuthority(int userId,String... authority) {
+		UserDetail userDetail = userAuthoricationDao.queryUserDetailInformation(userId);
+		if(userDetail==null){
+			throw new RuntimeException("用户信息不存在");
+		}
+		List<String> roleList = userDetail.getRole_name();
+		boolean temp = false;
+		for (String string : authority) {
+			temp=roleList.contains(string)||temp;
+		}
+		if(!temp){
+			throw new RuntimeException("无权查看项目文档信息");
+		}
+		return userDetail;
+		/*if(!(roleList.contains("监管机构")||roleList.contains("省分行托管分中心档案保管岗"))){
+			throw new RuntimeException("无权查看项目文档信息");
+		}*/
+	}
 	
 	/*public static void main(String[] args) throws NoSuchAlgorithmException {
 		MessageDigest complete=MessageDigest.getInstance("MD5");

+ 434 - 35
ccb_fund_trusteeship/src/main/java/com/fuzamei/utils/ValidationUtil.java

@@ -10,6 +10,8 @@ import javax.validation.Validation;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 
+import org.springframework.util.StringUtils;
+
 import com.alibaba.fastjson.JSON;
 
 /**
@@ -19,72 +21,469 @@ import com.alibaba.fastjson.JSON;
  * @describe 针对该项目中其它各类数据校验的工具类
  */
 public class ValidationUtil {
-	
-	private ValidationUtil(){
+
+	private ValidationUtil() {
 		throw new AssertionError("不能实例化 ValidationUtil");
 	}
-	
+
 	/**
-	* @Title: validate
-	* @Description: TODO(仅针对校验一个实体类的所有校验失败信息)
-	* @return List<String> 返回的是数据校验的所有校验失败信息,封装在一个list中作为返回值
-	* @author ylx
-	* @date 2017年12月26日 下午3:48:40
+	 * @Title: validate
+	 * @Description: TODO(仅针对校验一个实体类的所有校验失败信息)
+	 * @return List<String> 返回的是数据校验的所有校验失败信息,封装在一个list中作为返回值
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
 	 */
-	public static <T> List<String> validate(T bo){
+	public static <T> List<String> validate(T bo) {
 		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
 		Validator validator = factory.getValidator();
 		Set<ConstraintViolation<T>> validateSet = validator.validate(bo);
-		List<String> list=new ArrayList<String>();
+		List<String> list = new ArrayList<String>();
 		for (ConstraintViolation<T> validate : validateSet) {
 			list.add(validate.getMessage());
 		}
-		return list;	//包含所有校验出错的信息
-		
-		/*使用hibernate validator出现上面的错误, 需要 注意
-		@NotNull 和 @NotEmpty  和@NotBlank 区别
-		@NotEmpty 用在集合类上面
-		@NotBlank 用在String上面
-		@NotNull    用在基本类型上*/
+		return list; // 包含所有校验出错的信息
+
+		/*
+		 * 使用hibernate validator出现上面的错误, 需要 注意
+		 * 
+		 * @NotNull 和 @NotEmpty 和@NotBlank 区别
+		 * 
+		 * @NotEmpty 用在集合类上面
+		 * 
+		 * @NotBlank 用在String上面
+		 * 
+		 * @NotNull 用在基本类型上
+		 */
+	}
+
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行校验范围------>Int类型)
+	 * @return boolean
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static boolean checkRangeOfInt(final Object obj, int min, int max) {
+		String number = null;
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			number = String.class.cast(obj);
+			try {
+				Integer.parseInt(number);
+			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
+		} catch (Exception e) {
+			if (e instanceof NullPointerException) {
+				throw new NullPointerException("对象为null");
+			}
+			if (e instanceof NumberFormatException) {
+				throw new RuntimeException("数据类型解析异常");
+			}
+			Integer num = null;
+			try {
+				num = Integer.class.cast(obj);
+			} catch (Exception e1) {
+				throw new RuntimeException("数字解析异常");
+			}
+			if (num < min) {
+				throw new RuntimeException("最小值应该大于等于"+min);
+			}
+			if(num > max){
+				throw new RuntimeException("最大值应该小于等于"+max);
+			}
+		}
+		return true;
+	}
+
+	public static boolean checkMinOfInt(final Object obj, int min) {
+		return checkRangeOfInt(obj, min, Integer.MAX_VALUE);
+	}
+
+	public static boolean checkMaxOfInt(final Object obj, int max) {
+		return checkRangeOfInt(obj, Integer.MIN_VALUE, max);
+	}
+	
+	public static boolean checkOfInt(final Object obj) {
+		return checkRangeOfInt(obj, Integer.MIN_VALUE, Integer.MAX_VALUE);
 	}
 	
+
 	/**
-	* @Title: range
-	* @Description: TODO(针对传入的参数进行校验)
-	* @return void
-	* @author ylx
-	* @date 2017年12月26日 下午3:48:40
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行校验--->Long类型)
+	 * @return void
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
 	 */
-	public static void range(Object obj,int min,Class<? extends Number> clazz){
-		String number=null;
+	public static boolean checkRangeOfLong(final Object obj, long min, long max) {
+		String number = null;
 		try {
-			number=String.class.cast(obj);
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			number = String.class.cast(obj);
 			try {
 				Long.parseLong(number);
 			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
+		} catch (Exception e) {
+			if (e instanceof NullPointerException) {
+				throw new NullPointerException("对象为null");
+			}
+			if (e instanceof NumberFormatException) {
+				throw new RuntimeException("数据类型解析异常");
+			}
+			Long num = null;
+			try {
+				num = Long.class.cast(obj);
+			} catch (Exception e1) {
+				throw new RuntimeException("数字解析异常");
+			}
+			if (num < min) {
+				throw new RuntimeException("最小值应该大于等于"+min);
+			}
+			if(num > max){
+				throw new RuntimeException("最大值应该小于等于"+max);
+			}
+		}
+		return true;
+	}
+
+	public static boolean checkMinOfLong(final Object obj, long min) {
+		return checkRangeOfLong(obj, min, Long.MAX_VALUE);
+	}
+
+	public static boolean checkMaxOfLong(final Object obj, long max) {
+		return checkRangeOfLong(obj, Long.MIN_VALUE, max);
+	}
+	
+	public static boolean checkOfLong(final Object obj, long max) {
+		return checkRangeOfLong(obj, Long.MIN_VALUE, Long.MAX_VALUE);
+	}
+
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行校验--->Int类型,校验和赋值同时进行,同时返回真实的int数值)
+	 * @return int
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static int checkRangeAndAssignInt(final Object obj, int min, int max) {
+		String number = null;
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			number = String.class.cast(obj);
+			try {
+				return Integer.parseInt(number);
+			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
+		} catch (Exception e) {
+			if (e instanceof NullPointerException) {
+				throw new NullPointerException("对象为null");
+			}
+			if (e instanceof NumberFormatException) {
 				throw new RuntimeException("数据类型解析异常");
 			}
+			Integer num = null;
+			try {
+				num = Integer.class.cast(obj);
+			} catch (Exception e1) {
+				throw new RuntimeException("数字解析异常");
+			}
+			if (num < min) {
+				throw new RuntimeException("最小值应该大于等于"+min);
+			}
+			if(num > max){
+				throw new RuntimeException("最大值应该小于等于"+max);
+			}
+			return num;
+		}
+	}
+
+	public static int checkMinAndAssignInt(final Object obj, int min) {
+		return checkRangeAndAssignInt(obj,min,Integer.MAX_VALUE);
+	}
+	
+	public static int checkMaxAndAssignInt(final Object obj, int max) {
+		return checkRangeAndAssignInt(obj,Integer.MIN_VALUE,max);
+	}
+	
+	public static int checkAndAssignInt(final Object obj) {
+		return checkRangeAndAssignInt(obj,Integer.MIN_VALUE,Integer.MAX_VALUE);
+	}
+	
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行校验--->Long类型,校验和赋值同时进行,同时返回真实的long数值)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static long checkRangeAndAssignLong(final Object obj, long min, long max) {
+		String number = null;
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			number = String.class.cast(obj);
+			try {
+				return Long.parseLong(number);
+			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
 		} catch (Exception e) {
-			if(e.getMessage().equals("数据类型解析异常")){
+			if (e instanceof NullPointerException) {
+				throw new NullPointerException("对象为null");
+			}
+			if (e instanceof NumberFormatException) {
 				throw new RuntimeException("数据类型解析异常");
 			}
-			Number num=null;
+			Long num = null;
 			try {
-				num = clazz.cast(obj);
+				num = Long.class.cast(obj);
 			} catch (Exception e1) {
 				throw new RuntimeException("数字解析异常");
 			}
-			if(num.longValue()<min){
-				throw new RuntimeException("最小值应为"+min);
+			if (num < min) {
+				throw new RuntimeException("最小值应该大于等于"+min);
+			}
+			if(num > max){
+				throw new RuntimeException("最大值应该小于等于"+max);
 			}
+			return num;
 		}
-		
-		
 	}
 	
-	public static void main(String[] args) {
-		Map<String,Object> map = JSON.parseObject("{'KEY1':'033','KEY2':5}", Map.class);
-		range(map.get("KEY1"), 0, Integer.class);
+	public static long checkMinAndAssignLong(final Object obj, long min) {
+		return checkRangeAndAssignLong(obj,min,Long.MAX_VALUE);
+	}
+	
+	public static long checkMaxAndAssignLong(final Object obj, long max) {
+		return checkRangeAndAssignLong(obj,Long.MIN_VALUE,max);
 	}
 	
+	public static long checkAndAssignLong(final Object obj) {
+		return checkRangeAndAssignLong(obj,Long.MIN_VALUE,Long.MAX_VALUE);
+	}
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行非空(null)校验并返回string数据类型--->只针对String类型,校验和赋值同时进行,同时返回真实的String值)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static String checkNullAndAssignString(final Object obj){
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			String str=String.class.cast(obj);
+			return str;
+		} catch (Exception e) {
+			if(e instanceof NullPointerException){
+				throw new NullPointerException("对象为null");
+			}
+			if(e instanceof ClassCastException){
+				throw new ClassCastException("强转String类型异常");
+			}
+			throw new RuntimeException();
+		}
+	}
+	
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行非空(null)和空字符串("")校验并返回string数据类型--->只针对String类型,校验和赋值同时进行,同时返回真实的String值)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static String checkEmptyAndAssignString(final Object obj){
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			String str=String.class.cast(obj);
+			if("".equals(str)){
+				throw new RuntimeException("字符串不能为空");
+			}
+			return str;
+		} catch (Exception e) {
+			if(e instanceof NullPointerException){
+				throw new NullPointerException("对象为null");
+			}
+			if(e instanceof ClassCastException){
+				throw new ClassCastException("强转String类型异常");
+			}
+			throw new RuntimeException(e.getMessage());
+		}
+	}
+	
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行非空(null)和空字符串("")和空内容的字符串("   ")校验并返回string数据类型--->只针对String类型,校验和赋值同时进行,同时返回真实的String值)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static String checkBlankAndAssignString(final Object obj){
+		try {
+			if (obj == null) {
+				throw new NullPointerException();
+			}
+			String str=String.class.cast(obj);
+			if("".equals(str.trim())){
+				throw new RuntimeException("字符串不能无任何内容");
+			}
+			return str;
+		} catch (Exception e) {
+			if(e instanceof NullPointerException){
+				throw new NullPointerException("对象为null");
+			}
+			if(e instanceof ClassCastException){
+				throw new ClassCastException("强转String类型异常");
+			}
+			throw new RuntimeException(e.getMessage());
+		}
+	}
+	
+	
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行非空(null)和空字符串("")和空内容的字符串("   ")校验并返回string数据类型,只要是null,""或"  "全部返回null,不会抛出异常,除非无法强转为String,其它情况正常转String)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static String checkBlankStringAndAssignNullIfIsBlank(final Object obj){
+		try {
+			if (obj == null) {
+				return null;
+			}
+			String str=String.class.cast(obj);
+			if("".equals(str.trim())){
+				return null;
+			}
+			return str;
+		} catch (Exception e) {
+			throw new RuntimeException("String类型转换异常");
+		}
+	}
+	
+	/**
+	 * @Title: range
+	 * @Description: TODO(针对传入的参数进行非空(null)和空字符串("")和空内容的字符串("   ")校验并返回string数据类型,只要是null,""或"  "全部返回""空串,不会抛出异常,除非无法强转为String,其它情况正常转String)
+	 * @return long
+	 * @author ylx
+	 * @date 2017年12月26日 下午3:48:40
+	 */
+	public static String checkBlankStringAndAssignEmptyIfIsBlank(final Object obj){
+		try {
+			if (obj == null) {
+				return "";
+			}
+			String str=String.class.cast(obj);
+			if("".equals(str.trim())){
+				return "";
+			}
+			return str;
+		} catch (Exception e) {
+			throw new RuntimeException("String类型转换异常");
+		}
+	}
+	
+	/**
+	 * 
+	* @Title: checkAndAssignDefaultInt
+	* @Description: TODO(如果校验的Object不能转换Int则抛出异常,如果是null,空字符串或者是长空串,统一返回默认的值)
+	* @return int    返回类型
+	* @author ylx
+	* @date 2017年12月27日 下午1:51:43
+	 */
+	public static int checkAndAssignDefaultInt(final Object obj,int defaultInt){
+		String number = null;
+		try {
+			if (obj == null) {
+				return defaultInt;
+			}
+			number = String.class.cast(obj);
+			if("".equals(number.trim())){
+				return defaultInt;
+			}
+			try {
+				return Integer.parseInt(number);
+			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
+		} catch (Exception e) {
+			if (e instanceof NumberFormatException) {
+				throw new RuntimeException("数据类型解析异常");
+			}
+			Integer num = null;
+			try {
+				num = Integer.class.cast(obj);
+			} catch (Exception e1) {
+				throw new RuntimeException("数字解析异常");
+			}
+			return num;
+		}
+	}
+	
+	
+	/**
+	 * 
+	* @Title: checkAndAssignDefaultLong
+	* @Description: TODO(如果校验的Object不能转换Long则抛出异常,如果是null,空字符串或者是长空串,统一返回默认的值)
+	* @Attention: 这里要特别注意以下,如果前端传过来的数据是小于Integer.MAX_VALUE的话,必须要加L来将数据强制转化为Long类型,不然解析失败
+	* @return long    返回类型
+	* @author ylx
+	* @date 2017年12月27日 下午1:51:43
+	 */
+	public static long checkAndAssignDefaultLong(final Object obj,long defaultLong){
+		String number = null;
+		try {
+			if (obj == null) {
+				return defaultLong;
+			}
+			number = String.class.cast(obj);
+			if("".equals(number.trim())){
+				return defaultLong;
+			}
+			try {
+				return Long.parseLong(number);
+			} catch (NumberFormatException e) {
+				throw new NumberFormatException();
+			}
+		} catch (Exception e) {
+			if (e instanceof NumberFormatException) {
+				throw new RuntimeException("数据类型解析异常");
+			}
+			Long num = null;
+			try {
+				num=Long.parseLong(""+obj);
+			} catch (Exception e1) {
+				throw new RuntimeException("数字解析异常");
+			}
+			return num;
+		}
+	}
+	
+
+	public static void main(String[] args) {
+		String json="{'KEY1':'12','KEY2':23,'KEY3':null}";
+		Map parseObject = JSON.parseObject(json, Map.class);
+		Object obj=20000000;
+		long checkAndAssignDefaultLong = checkAndAssignDefaultLong(obj,1000);
+		System.out.println(checkAndAssignDefaultLong);
+//		Long.class.cast(obj
+//		Long cast = Long.class.cast(1L);
+//		System.out.println(checkAndAssignDefaultLong);
+	}
+
 }

+ 96 - 22
ccb_fund_trusteeship/src/main/java/com/fuzamei/web/OperationHistoryAction.java

@@ -18,9 +18,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.alibaba.fastjson.JSON;
 import com.fuzamei.entity.OperationHistoryBO;
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.service.OperationHistoryService;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.PageDTO;
+import com.fuzamei.utils.StringUtil;
 import com.fuzamei.utils.ValidationUtil;
 
 
@@ -31,12 +33,15 @@ public class OperationHistoryAction {
 	@Autowired
 	private OperationHistoryService operationHistoryService;
 	
+	
+	private static final int ROW_NUM = 10; // 分页每页显示数据的数量
 	/**
 	 * 
 	* @Title: queryOperationHistoryInformation
 	* @Description: TODO(查询操作记录信息....)
 	* @param @param data--前台传递过来的application/json数据
 	* 				传递过来的参数json格式为:
+	* 				全部是字符串
 					{
 						"userId":"xxx",
 						"page":"1",			
@@ -52,40 +57,109 @@ public class OperationHistoryAction {
 	* @date 2017年12月14日 下午5:12:17
 	* @throws
 	 */
+	@SuppressWarnings("unchecked")
 	@RequestMapping(value="/queryOperationHistoryInformation",method=RequestMethod.POST)
 	@ResponseBody
 	public Map<String,Object> queryOperationHistoryInformation(@RequestBody String data){
 		try {
 			System.out.println("查询操作记录信息....");
-//			Map<String, Object> map = JSONUtil.jsonToMap(data);		//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
-//			PageDTO pageDto = operationHistoryService.queryOperationHistoryInformation(map);	
-
-			OperationHistoryBO operationHistoryBO = JSON.parseObject(data, OperationHistoryBO.class);
-			List<String> validateList = ValidationUtil.validate(operationHistoryBO);
-			if(!validateList.isEmpty()){
-				throw new RuntimeException(validateList.get(0));	//抛出校验失败异常
+			Map<String, String> map = JSON.parseObject(data, Map.class);	//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));	//userId只要是一个int类型即可
+			int page = ValidationUtil.checkMinAndAssignInt(map.get("page"), 1); // 默认页是第一页
+			String account = ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("account")); // 账号默认空值""(空串,也可以是null,根据需求改)
+			String role = ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("role")); // 操作角色默认空值""
+			String type = ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("type"));; // 操作类型默认空值""
+			long startTime = ValidationUtil.checkAndAssignDefaultLong(map.get("startTime"), 0); // 开始时间默认0
+			long endTime = ValidationUtil.checkAndAssignDefaultLong(map.get("endTime"), Long.MAX_VALUE); // 结束时间默认Long最大值
+			Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
+			mapToService.put("userId", userId);					//用户id用于查询权限或者角色信息
+			mapToService.put("startPage", (page - 1) * ROW_NUM);
+			mapToService.put("account", account);
+			mapToService.put("role", role);
+			mapToService.put("type", type);
+			if (startTime <= endTime) {
+				mapToService.put("startTime", startTime);
+				mapToService.put("endTime", endTime);
+			} else {
+				mapToService.put("startTime", startTime);
+				mapToService.put("endTime", Long.MAX_VALUE);
 			}
-			PageDTO pageDto = operationHistoryService.queryOperationHistoryInformation(operationHistoryBO);
+			mapToService.put("rowNum", ROW_NUM); //默认每页显示数据是10条,可根据需求修改分页数量
+			PageDTO pageDto = operationHistoryService.queryOperationHistoryInformation(mapToService);
 			return JSONUtil.getJsonMap(200, true, "查询成功", pageDto);
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, "查询失败:"+e.getMessage(), null);
 		}
 	}
 	
-	/*//算数据库中bigint的时间用的
-	public static void main(String[] args) throws ParseException {
-		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
-		Scanner scan=new Scanner(System.in);
-		while(true){
-		String str=scan.next();
-		Date parse = sdf.parse(str);
-		System.out.println(parse.getTime());
-		}
-		
-	}*/
 	
-	/*public static void main(String[] args) {
-		System.out.println(Long.MAX_VALUE);
-		System.out.println(Integer.parseInt("1.1"));
+	
+	/*@RequestMapping(value="/test",method=RequestMethod.POST)
+	@ResponseBody
+	public Map<String,Object> test(@RequestBody String data){
+		int userId=15254122;
+		UserDetail detail=operationHistoryService.queryUserDetailInformation(userId);
+		System.out.println(detail);
+		return JSONUtil.getJsonMap(200, true, "查询成功", null);
 	}*/
+	
+	/*OperationHistoryBO operationHistoryBO = JSON.parseObject(data, OperationHistoryBO.class);
+	List<String> validateList = ValidationUtil.validate(operationHistoryBO);
+	if(!validateList.isEmpty()){
+		throw new RuntimeException(validateList.get(0));	//抛出校验失败异常
+	}
+	PageDTO pageDto = operationHistoryService.queryOperationHistoryInformation(operationHistoryBO);*/
+	
+	/*if (StringUtil.isNotEmpty(map.get("userId"))) { 		// 等于空就直接取空值
+	try {
+		userId = Integer.parseInt((String) map.get("userId"));
+	} catch (Exception e) {
+		throw new RuntimeException("userId类型转换异常");
+	}
+}
+if (StringUtil.isNotEmpty(map.get("page"))) { 			// 等于空就直接取第一页
+	try {
+		page = Integer.parseInt((String) map.get("page"));
+		if (page < 1) {
+			page = 1;
+		}
+	} catch (Exception e) {
+		throw new RuntimeException("page类型转换异常");
+	}
+}
+if (StringUtil.isNotEmpty(map.get("account"))) { 		// 等于空就直接取空值
+	try {
+		account = (String) map.get("account");
+	} catch (Exception e) {
+		throw new RuntimeException("account类型转换异常");
+	}
+}
+if (StringUtil.isNotEmpty(map.get("role"))) { 			// 等于空就直接取空值
+	try {
+		role = (String) map.get("role");
+	} catch (Exception e) {
+		throw new RuntimeException("role类型转换异常");
+	}
+}
+if (StringUtil.isNotEmpty(map.get("type"))) { 			// 等于空就直接取空值
+	try {
+		type = (String) map.get("type");
+	} catch (Exception e) {
+		throw new RuntimeException("type类型转换异常");
+	}
+}
+if (StringUtil.isNotEmpty(map.get("startTime"))) { // 等于空就直接取空值
+	try {
+		startTime = Long.parseLong((String) map.get("startTime"));
+	} catch (Exception e) {
+		throw new RuntimeException("startTime类型转换异常");// 数据解析异常或转换类型异常startTime还是0
+	}
+}
+if (StringUtil.isNotEmpty(map.get("endTime"))) { // 等于空就直接取空值
+	try {
+		endTime = Long.parseLong((String) map.get("endTime"));
+	} catch (Exception e) {
+		throw new RuntimeException("endTime类型转换异常");// 数据解析异常或转换类型异常endTime还是9223372036854775807L
+	}
+}*/
 }

+ 123 - 44
ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ProjectFileAction.java

@@ -26,9 +26,13 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.multipart.MultipartFile;
 
+import com.alibaba.fastjson.JSON;
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.service.ProjectFileService;
+import com.fuzamei.utils.HashXiZhiUtil;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.PageDTO;
+import com.fuzamei.utils.ValidationUtil;
 
 @Controller
 @RequestMapping("/project_file")
@@ -37,6 +41,8 @@ public class ProjectFileAction {
 	@Autowired
 	private ProjectFileService projectFileService;
 
+	private static final int ROW_NUM = 10; // 分页每页显示数据的数量(固定10条数据)
+	
 	private static final String SP = File.separator;
 	/**
 	 * 
@@ -45,6 +51,7 @@ public class ProjectFileAction {
 	 * TODO(获取项目文档信息,用于展示项目文档基本信息展示) 
 	 * 			以下为前端传递过来的参数
 				 {
+				 	"userId":"XXX"
 					"page":"1",
 					"projectName":"",
 					"startTime":"",
@@ -57,23 +64,47 @@ public class ProjectFileAction {
 	 * @author ylx 
 	 * @date 2017年12月15日下午1:24:40
 	 */
+	@SuppressWarnings("unchecked")
 	@RequestMapping(value = "/queryProjectFileInformation")
 	@ResponseBody
 	public Map<String, Object> queryProjectFileInformation(@RequestBody String data) {
-
-		System.out.println("查询项目文档记录信息....");
-
-		Map<String, Object> map = JSONUtil.jsonToMap(data);
-
-		PageDTO pageDto = projectFileService.queryProjectFileInformation(map); // 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
-
-		return JSONUtil.getJsonMap(200, true, "操作成功", pageDto);
+		try {
+			System.out.println("查询项目文档记录信息....");
+			Map<String, String> map = JSON.parseObject(data, Map.class);	//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));	//userId只要是一个int类型即可
+			int page = ValidationUtil.checkMaxAndAssignInt(map.get("page"), 1); // 默认页数是第一页
+			String projectName = ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("projectName")); // 默认名称为空值
+			long startTime = ValidationUtil.checkAndAssignDefaultLong(map.get("startTime"), 0); // 默认起始时间为0
+			long endTime = ValidationUtil.checkAndAssignDefaultLong(map.get("endTime"), Long.MAX_VALUE); // 默认终止时间为Long最大值
+			Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
+			mapToService.put("userId", userId);					//用户id用于查询权限或者角色信息
+			mapToService.put("startPage", (page - 1) * ROW_NUM);
+			mapToService.put("projectName", projectName);
+			if (startTime <= endTime) {
+				mapToService.put("startTime", startTime);
+				mapToService.put("endTime", endTime);
+			} else {
+				mapToService.put("startTime", startTime);
+				mapToService.put("endTime", Long.MAX_VALUE);
+			}
+			mapToService.put("rowNum", ROW_NUM); // 默认每页显示数据是10条,可根据需求修改分页数量
+			PageDTO pageDto = projectFileService.queryProjectFileInformation(mapToService); // 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
+			return JSONUtil.getJsonMap(200, true, "查询成功", pageDto);
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, "查询失败:"+e.getMessage(), null);
+		}
 	}
 	
 	/**
 	 * 
 	* @Title: checkoutProjectFiles
 	* @Description: TODO--------------->>显示下载文件的提示框
+	* 				以下为前端传递过来的参数
+				 {
+				 	"userId":"XXX"
+					"projectId":"",
+					"projectName":"",
+				}
 	* @param @param data
 	* @param @return    设定文件
 	* @return Map<String,Object>    返回类型
@@ -81,25 +112,33 @@ public class ProjectFileAction {
 	* @date 2017年12月15日 下午8:09:44
 	* @throws
 	 */
+	@SuppressWarnings("unchecked")
 	@RequestMapping(value = "/checkoutProjectFiles")
 	@ResponseBody
 	public Map<String, Object> checkoutProjectFiles(@RequestBody String data){
-		
-		System.out.println("项目文档查看....");
-		
-		Map<String, Object> map = JSONUtil.jsonToMap(data);	// 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
-		
-		Map<String, Object> mapFromService = projectFileService.checkoutProjectFiles(map); //由于这里不需要分页,只要service传过来一个map对象即可
-		
-		return JSONUtil.getJsonMap(200, true, "操作成功", mapFromService); //将从service返回回来的map对象通过map对象直接返回给前端
+		try {
+			System.out.println("项目文档查看....");
+			Map<String, Object> map = JSON.parseObject(data, Map.class);	// 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));	//userId只要是一个int类型即可
+			Integer projectId = ValidationUtil.checkAndAssignDefaultInt(map.get("projectId"),0);	//默认项目编号为空
+			String projectName=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("projectName"));		//默认项目名称为空值
+			Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
+			mapToService.put("userId", userId);
+			mapToService.put("projectId", projectId);
+			mapToService.put("projectName", projectName);
+			Map<String, Object> mapFromService = projectFileService.checkoutProjectFiles(map); //由于这里不需要分页,只要service传过来一个map对象即可
+			return JSONUtil.getJsonMap(200, true, "查询成功", mapFromService); //将从service返回回来的map对象通过map对象直接返回给前端
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, "查询失败"+e.getMessage(), null); 
+		}
 	}
 	
 	/**
 	 * 
 	* @Title: download
 	* @Description: TODO(项目文档中的文件下载功能实现)
-	* @param @param request
-	* @param @param response
+	* 				前端传来一个get或post请求
+	* 				
 	* @param @param url    设定文件
 	* @return void    返回类型
 	* @author ylx
@@ -108,9 +147,15 @@ public class ProjectFileAction {
 	 */
 	@RequestMapping(value="/downloadProjectFile")
 	@ResponseBody
-	public Map<String, Object> download(HttpServletRequest request,HttpServletResponse response,@RequestParam("url") String url) {
+	public Map<String, Object> download(HttpServletRequest request,HttpServletResponse response,@RequestParam("url") String url,@RequestParam("userId") Object id) {
 		try {
+			int userId=ValidationUtil.checkAndAssignInt(id);
+			projectFileService.checkUserAuthority(userId,"监管机构","省分行托管分中心档案保管岗");//查看用户是否为空及是否有权限下载项目文档文件
 			String fileName = request.getServletContext().getRealPath("")+url;  		//SP是系统分隔符
+			//如果文件不存在直接抛出异常
+			if(!new File(fileName).exists()){
+				throw new RuntimeException("文件不存在");
+			}
 			InputStream bis = new BufferedInputStream(new FileInputStream(new File(fileName)));  
 			String filename = url.substring(url.lastIndexOf("/")+1);  //截取文件名
 			filename = URLEncoder.encode(filename,"UTF-8");
@@ -134,52 +179,86 @@ public class ProjectFileAction {
 	 * 
 	* @Title: showUploadProjectFileInterface
 	* @Description: TODO------------->>显示项目文档上传的界面
+	* 			以下为前端传递过来的参数
+				 {
+				 	"userId":"XXX"
+					"projectId":"",
+					"projectName":"",
+				}
 	* @param @return    设定文件
 	* @return Map<String,Object>    返回类型
 	* @author ylx
 	* @date 2017年12月15日 下午8:11:09
 	* @throws
 	 */
-	/*@RequestMapping(value = "/showUploadProjectFileInterface")
+	@SuppressWarnings("unchecked")
+	@RequestMapping(value = "/showUploadProjectFileInterface")
 	@ResponseBody
-	public Map<String, Object> showUploadProjectFileInterface(){
-		
-	}*/
+	public Map<String, Object> showUploadProjectFileInterface(@RequestBody String data){
+		try {
+			Map<String,Object> map = JSON.parseObject(data, Map.class);
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));	//userId只要是一个int类型即可
+			projectFileService.checkUserAuthority(userId,"省分行托管分中心档案保管岗");		//该权限只有	【省分行托管分中心档案保管岗】才能操作
+			Integer projectId = ValidationUtil.checkAndAssignDefaultInt(map.get("projectId"),0);	//默认项目编号为空
+			String projectName=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("projectName"));		//默认项目名称为空值
+			Map<String, Object> mapToClient =new LinkedHashMap<String, Object>();
+			mapToClient.put("projectId", projectId);
+			mapToClient.put("projectName", projectName);
+			return JSONUtil.getJsonMap(200, true, "查询成功", mapToClient); //将从service返回回来的map对象通过map对象直接返回给前端
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, "查看出现异常:"+e.getMessage(),null); //返回给前端一个map进行前段提示
+		}
+	}
 	
+	/**
+	 * 
+	* @Title: upload
+	* @Description: TODO(用户通过上传文件的界面上传文件,需要通过表单的形式将文件上传到服务器制定的存放路径)
+	* 			以下是表单的格式信息(按照一次一个文件上传)
+	* 			【userId:用户id号
+	* 			  file:上传的文件
+	* 			  projectId:项目id号
+	* 			  projectName:项目名称】
+	* 
+	* @param @param projectId
+	* @param @param projectName
+	* @param @param id
+	* @return Map<String,Object>    返回类型
+	* @author ylx
+	* @date 2017年12月27日 下午5:32:18
+	 */
 	@RequestMapping(value="/uploadProjetcFile",method=RequestMethod.POST)
 	@ResponseBody
-	public Map<String, Object> upload(@RequestParam("file") MultipartFile file,HttpServletRequest request,@RequestParam("projectId") String projectId,@RequestParam("projectName") String projectName ) {
-		
-//		Map<String, Object> map = JSONUtil.jsonToMap(data);	// 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
-		
+	public Map<String, Object> upload(@RequestParam("file") MultipartFile file,HttpServletRequest request,@RequestParam("projectId") String pId,@RequestParam("projectName") String pName,@RequestParam("userId") Object uId) {
 		try {
-			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符	
+			int userId=ValidationUtil.checkAndAssignInt(uId);
+			UserDetail userDetail = projectFileService.checkUserAuthority(userId,"监管机构","省分行托管分中心档案保管岗");//查看用户是否为空及是否有权限下载项目文档文件
+			String projectId = ValidationUtil.checkBlankAndAssignString(pId);				//校验projectId并赋值
+			String projectName = ValidationUtil.checkBlankAndAssignString(pName);			//校验projectName并赋值
+			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符,path是存放上传文件的父类文件夹绝对路径	
 			File dir=new File(path);
 			if(!dir.exists()){
 				dir.mkdirs();
 			}
-			
-			String filename = file.getOriginalFilename();
-			String pathFile=path+SP+filename;
+			String filename = file.getOriginalFilename();									//filename是上传文件的真实文件名
+			String pathFile=path+SP+filename;												//pathFile是该文件在系统中的绝对路径
 			File newFile=new File(pathFile);
-			file.transferTo(newFile);
-			
-			Map<String, Object> map =new LinkedHashMap<String, Object>();
-			
-			map.put("projectId", projectId);
-			map.put("projectName", projectName);
-			map.put("url", "/content/"+filename);		//将文件下载路径url通过map传到service层进行校验
-			map.put("attachmentName", filename);			//将文件以附件名的形式通过map传递到service层中进行校验
-			
-			projectFileService.insertInformationIntoTable(map);		//将获取到的数据插入到表中
-			
+			file.transferTo(newFile);														//文件已经上传成功
+			String fileHash = HashXiZhiUtil.getMD5Checksum(filename);						//文件上传后计算文件的hash值=============>>换hash算法这里直接换掉即可			
+			Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
+			mapToService.put("userDetail", userDetail);				//将用户的信息传入
+			mapToService.put("projectId", projectId);
+			mapToService.put("projectName", projectName);
+			mapToService.put("url", "/content/"+filename);			//将文件下载路径url通过map传到service层进行校验
+			mapToService.put("attachmentName", filename);			//将文件以附件名的形式通过map传递到service层中进行校验
+			mapToService.put("hash", fileHash);						//将上传的文件hash值放入map
+			projectFileService.insertInformationIntoTable(mapToService);		//将获取到的数据插入到各类表中
 			Map<String, Object> mapResult = JSONUtil.getJsonMap(200, true, "上传成功",null); //返回给前端一个map进行前段提示
 			return mapResult;
 		} catch (Exception e) {
-			Map<String, Object> mapResult = JSONUtil.getJsonMap(500, true, "上传出现异常"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			Map<String, Object> mapResult = JSONUtil.getJsonMap(500, true, "上传出现异常:"+e.getMessage(),null); //返回给前端一个map进行前段提示
 			return mapResult;
 		}
-		
 	}
 	
 }