Browse Source

reconstruct

ylx 7 years ago
parent
commit
cb0fa3b22c
20 changed files with 661 additions and 243 deletions
  1. 15 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/BattleResult.java
  2. 22 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/HintMSG.java
  3. 3 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/OperationTypeId.java
  4. 3 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/Permission.java
  5. 4 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/Role.java
  6. 24 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/StatusId.java
  7. 16 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/AttachmentDao.java
  8. 12 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/ValuationAccountingDao.java
  9. 0 2
      ccb_fund_trusteeship/src/main/java/com/fuzamei/entity/ValuationAccount.java
  10. 9 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/AttachmentMapper.xml
  11. 78 1
      ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/ValuationAccountingMapper.xml
  12. 8 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/AttachmentMapper.java
  13. 8 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/ValuationAccountingMapper.java
  14. 27 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/service/AttachmentService.java
  15. 4 42
      ccb_fund_trusteeship/src/main/java/com/fuzamei/service/ProjectFileService.java
  16. 48 0
      ccb_fund_trusteeship/src/main/java/com/fuzamei/service/UserAuthoricationService.java
  17. 133 133
      ccb_fund_trusteeship/src/main/java/com/fuzamei/service/ValuationAccountingService.java
  18. 2 2
      ccb_fund_trusteeship/src/main/java/com/fuzamei/web/OperationHistoryAction.java
  19. 27 19
      ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ProjectFileAction.java
  20. 218 44
      ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ValuationAccountingAction.java

+ 15 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/BattleResult.java

@@ -0,0 +1,15 @@
+package com.fuzamei.constant;
+/**
+ * 
+ * @author ylx
+ * @describe 估值核算表中
+ *
+ */
+public class BattleResult {
+	private BattleResult() {
+		throw new AssertionError("禁止实例化");
+	}
+	public static final String TO_BE_MATCHED = "待对账";
+	public static final String CONSISTENT = "估值一致";
+	public static final String INCONSISTENT = "估值不一致";
+}

+ 22 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/HintMSG.java

@@ -0,0 +1,22 @@
+package com.fuzamei.constant;
+
+/**
+ * 
+ * @author ylx
+ * @descibe: 提示信息的类
+ */
+public class HintMSG {
+	private HintMSG() {
+		throw new AssertionError("禁止实例化");
+	}
+	public static final String DOWNLOAD_SUCCESS="文件下载成功";
+	public static final String DOWNLOAD_FAIL="文件下载失败";
+	public static final String UPLOAD_SUCCESS="文件上传成功";
+	public static final String UPLOAD_FAIL="文件上传失败";
+	public static final String QUERY_SUCCESS="查询成功";
+	public static final String QUERY_FAIL="查询失败";
+	public static final String CHECK_SUCCESS="查看成功";
+	public static final String CHECK_FAIL="查看失败";
+	public static final String FILE_NOT_FOUND="文件不存在";
+	public static final String FILE_CANT_BE_NULL="文件不能为空";
+}

+ 3 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/OperationTypeId.java

@@ -5,6 +5,9 @@ package com.fuzamei.constant;
  * @describe: 操作类型id号
  */
 public class OperationTypeId {
+	private OperationTypeId() {
+		throw new AssertionError("禁止实例化");
+	}
 	public static final Integer BUSINESS_APPLY =1001;						//业务申报
 	public static final Integer BUSINESS_FIRST_TRIAL_AGREED =1002;			//业务初审通过
 	public static final Integer BUSINESS_REEXAMINE_REJECTED =1003;			//业务复审拒绝

+ 3 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/Permission.java

@@ -7,6 +7,9 @@ package com.fuzamei.constant;
  * @date: 2017-12-28 10:12 am
  */
 public class Permission {
+	private Permission() {
+		throw new AssertionError("禁止实例化");
+	}
 	public static final String ADD="添加";
 	public static final String FIRST_TRIAL="初审";
 	public static final String REEXAMINE="复审";

+ 4 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/Role.java

@@ -7,6 +7,9 @@ package com.fuzamei.constant;
  * @Date:2017-12-28 10:08 am
  */
 public class Role {
+	private Role() {
+		throw new AssertionError("禁止实例化");
+	}
 	//TRAN is abbreviation of transactor
 	public static final String TRAN_BRANCH_BANK = "经办支行";
 	//SEC is abbreviation of secondary
@@ -31,4 +34,5 @@ public class Role {
 	public static final String VENTURE_MANAGEMENT_POS = "风管岗";
 	public static final String OTHER_POS = "其余岗";
 	public static final String INNERS_OF_BANK = "银行内部人员";
+	
 }

+ 24 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/constant/StatusId.java

@@ -0,0 +1,24 @@
+package com.fuzamei.constant;
+
+/**
+ * 
+ * @author ylx
+ * @describe: 对应状态id号
+ */
+public class StatusId {
+	private StatusId() {
+		throw new AssertionError("禁止实例化");
+	}
+	public static final Integer TO_BE_CHECKED_BY_SECONDARY_BRANCH_BANK = 1;	//待二级分行审核
+	public static final Integer REJECTED_BY_SECONDARY_BRANCH_BANK = 2;		//二级分行审核不通过
+	public static final Integer TO_BE_CHECKED_BY_PROVINCIAL_BRANCH_BANK = 3;//待省分行业务部门审核
+	public static final Integer REJECTED_BY_PROVINCIAL_BRANCH_BANK = 4;		//省分行业务部门审核不通过
+	public static final Integer AGREE = 5;									//通过
+	public static final Integer REJECTED = 6;								//不通过
+	public static final Integer MODIFYING = 7;								//修订中
+	public static final Integer CONFIRMED = 8;								//已确认
+	public static final Integer FINISHED = 9;								//已完成
+	public static final Integer LAUNCHING = 10;								//发起
+	public static final Integer CHECKING = 11;								//审核
+	
+}

+ 16 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/AttachmentDao.java

@@ -0,0 +1,16 @@
+package com.fuzamei.dao;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fuzamei.mapperInterface.AttachmentMapper;
+
+public class AttachmentDao {
+	
+	@Autowired
+	private AttachmentMapper attachmentMapper;
+
+	public int queryIfHasTheSameAttachmentId(Integer attachmentId) {
+		return attachmentMapper.queryIfHasTheSameAttachmentId(attachmentId);
+	}
+
+}

+ 12 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/dao/ValuationAccountingDao.java

@@ -39,4 +39,16 @@ public class ValuationAccountingDao {
 		valuationAccountingMapper.insertInformationToAttachment(map);
 	}
 
+	public List<ValuationAccount> checkoutDownloadInformation(int fundId) {
+		return valuationAccountingMapper.checkoutDownloadInformation(fundId);
+	}
+
+	public int queryIfHasTheSameFundId(Integer fundId) {
+		return valuationAccountingMapper.queryIfHasTheSameFundId(fundId);
+	}
+
+	public ValuationAccount checkIfFundExists(Integer fundId, String fundName) {
+		return valuationAccountingMapper.checkIfFundExists(fundId,fundName);
+	}
+
 }

+ 0 - 2
ccb_fund_trusteeship/src/main/java/com/fuzamei/entity/ValuationAccount.java

@@ -62,8 +62,6 @@ public class ValuationAccount {
 	public void setBattle_result(String battle_result) {
 		this.battle_result = battle_result;
 	}
-	
-	
 	public String getAttachment_name_of_custodian() {
 		return attachment_name_of_custodian;
 	}

+ 9 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/AttachmentMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fuzamei.mapperInterface.AttachmentMapper"> 
+	
+	<select id="queryIfHasTheSameAttachmentId" resultType="int">
+		select count(*) from attachment where attachment_id=#{attachmentId}
+	</select>
+	
+</mapper>

+ 78 - 1
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapper/ValuationAccountingMapper.xml

@@ -56,7 +56,6 @@
 			temp.update_time asc
 		limit 
 			#{startPage},#{rowNum}
-		
 	</select>
 	
 	<!-- 管理岗上传管理人估值报表的时候插入的数据,分别插入valuation_accounting和attachment表,但是注意这个时候银行估值报表暂时不进行插入 -->
@@ -124,4 +123,82 @@
 			   #{hash})
 	</insert>
 	
+	<!-- 返回给下载提示框的数据 -->
+	<select id="checkoutDownloadInformation" resultType="com.fuzamei.entity.ValuationAccount">
+		select 
+			temp.fund_id,
+			temp.fund_name,
+			temp.assets_under_custody,
+			temp.attachment_name attachment_name_of_custodian,
+			att.attachment_name attachment_name_of_bank,
+			temp.url url_of_custodian,
+			att.url url_of_bank,
+		from
+			(select 
+				va.fund_id,
+				va.fund_name,
+				va.assets_under_custody,
+				att.attachment_name,
+				va.bank_valuation_id,
+				va.battle_result,
+				att.url,
+				va.update_time
+			 from 
+				valuation_accounting va
+			 left join 
+			 	attachment att
+			 on 
+			 va.custodian_valuation_id=att.attachment_id
+			 where 
+			 	va.fund_id=#{fundId}) temp 
+		left join 
+			attachment att
+		on 
+			temp.bank_valuation_id = att.attachment_id
+		order by 
+			temp.update_time asc
+	</select>
+	
+	<!-- 对是否有重复的fundId进行查询并返回重复结果 -->
+	<select id="queryIfHasTheSameFundId" resultType="int">
+		select count(*) from valuation_accounting where fund_id=#{fundId}
+	</select>
+	
+	<!-- 对是否有存在基金数据进行查询并返回查询到的结果 -->
+	<select id="checkIfFundExists" resultType="com.fuzamei.entity.ValuationAccount">
+		select 
+			temp.fund_id,
+			temp.fund_name,
+			temp.assets_under_custody,
+			temp.attachment_name attachment_name_of_custodian,
+			att.attachment_name attachment_name_of_bank,
+			temp.url url_of_custodian,
+			att.url url_of_bank,
+			temp.update_time,
+			temp.battle_result
+		from
+			(select 
+				va.fund_id,
+				va.fund_name,
+				va.assets_under_custody,
+				att.attachment_name,
+				va.bank_valuation_id,
+				va.battle_result,
+				att.url,
+				va.update_time
+			 from 
+				valuation_accounting va
+			 left join 
+			 	attachment att
+			 on 
+			 va.custodian_valuation_id=att.attachment_id) temp 
+		left join 
+			attachment att
+		on 
+			temp.bank_valuation_id = att.attachment_id
+		where
+			temp.fund_name=#{fundName} and temp.fund_id=#{fundId}
+
+	</select>
+	
 </mapper>

+ 8 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/AttachmentMapper.java

@@ -0,0 +1,8 @@
+package com.fuzamei.mapperInterface;
+
+
+public interface AttachmentMapper {
+
+	int queryIfHasTheSameAttachmentId(Integer attachmentId);
+	
+}

+ 8 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/mapperInterface/ValuationAccountingMapper.java

@@ -3,6 +3,8 @@ package com.fuzamei.mapperInterface;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.ibatis.annotations.Param;
+
 import com.fuzamei.entity.ValuationAccount;
 
 public interface ValuationAccountingMapper {
@@ -19,4 +21,10 @@ public interface ValuationAccountingMapper {
 
 	void insertInformationToAttachment(Map<String, Object> map);
 
+	List<ValuationAccount> checkoutDownloadInformation(int fundId);
+
+	int queryIfHasTheSameFundId(Integer fundId);
+
+	ValuationAccount checkIfFundExists(@Param("fundId") Integer fundId, @Param("fundName") String fundName);
+
 }

+ 27 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/AttachmentService.java

@@ -0,0 +1,27 @@
+package com.fuzamei.service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.fuzamei.dao.AttachmentDao;
+
+@Service
+public class AttachmentService {
+	
+	@Autowired
+	private AttachmentDao attachmentDao;
+	
+	public int generateAtachmentId(){
+		int same = 0;
+		Integer attachmentId = null;
+		//如果有重复的继续查,直到查不出重复的fundId号为止
+		while(same != 0){
+			attachmentId=(int)(Math.random()*1000000000);								//=========================>>>产生附件id号的机制要改的TODO
+			same = attachmentDao.queryIfHasTheSameAttachmentId(attachmentId);
+		}
+		return attachmentId;
+	}
+}

+ 4 - 42
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/ProjectFileService.java

@@ -1,8 +1,5 @@
 package com.fuzamei.service;
 
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -14,7 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
 import com.fuzamei.constant.OperationTypeId;
 import com.fuzamei.constant.Role;
 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;
@@ -26,7 +22,7 @@ public class ProjectFileService {
 	private ProjectFileDao projectFileDao;
 	
 	@Autowired
-	private UserAuthoricationDao userAuthoricationDao;
+	private UserAuthoricationService userAuthoricationService;
 
 	/**
 	 * 
@@ -43,7 +39,7 @@ public class ProjectFileService {
 		
 		PageDTO pageDto = new PageDTO(); // 创建分页对象
 		int userId = (Integer) map.get("userId");
-		checkUserAuthority(userId,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);		//查看用户非空和权限
+		userAuthoricationService.checkUserAuthority(userId,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);		//查看用户非空和权限
 		List<ProjectFile> informationList = projectFileDao.queryProjectFileInformation(map);
 		int count = projectFileDao.findAllInformation();
 		pageDto.setRows(informationList);
@@ -65,7 +61,7 @@ public class ProjectFileService {
 	 */
 	public Map<String, Object> checkoutProjectFiles(Map<String, Object> map) {
 		int userId = (Integer) map.get("userId");
-		checkUserAuthority(userId,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);	//查看用户非空和权限
+		userAuthoricationService.checkUserAuthority(userId,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);	//查看用户非空和权限
 		List<ProjectFile> informationList = projectFileDao.checkoutProjectFiles(map);	//将项目id和项目名称封装成map到dao层去获取数据
 		Map<String, Object> mapBackToController = new LinkedHashMap<String, Object>();
 		mapBackToController.put("projectId", map.get("projectId"));		//展示给前端的项目id号码
@@ -114,41 +110,10 @@ public class ProjectFileService {
 		mapToOperationHistory.put("operatorRole", Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);	//创建这个操作的角色只能是省分行托管分中心档案保管岗
 		mapToOperationHistory.put("operatorPerson", userDetail.getPerson_name());		//操作人通过userDetail中获取
 		mapToOperationHistory.put("operatorTime", currentTime);							//操作时间为当前操作时间
-		mapToOperationHistory.put("hash", map.get("hash"));								//如何计算操作的hash值?(按照上传的项目文件的hash值算)=====>>待定TODO
+		mapToOperationHistory.put("hash", "来自前端token计算");							//如何计算操作的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");
 		byte[] bs={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
@@ -164,7 +129,4 @@ public class ProjectFileService {
 		
 	}*/
 	
-
-
-	
 }

+ 48 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/UserAuthoricationService.java

@@ -0,0 +1,48 @@
+package com.fuzamei.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.fuzamei.dao.UserAuthoricationDao;
+import com.fuzamei.entity.UserDetail;
+
+@Service
+public class UserAuthoricationService {
+	
+	@Autowired
+	private UserAuthoricationDao userAuthoricationDao;
+	
+	
+	/**
+	 * 
+	* @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("无权查看项目文档信息");
+		}*/
+	}
+	
+	
+}

+ 133 - 133
ccb_fund_trusteeship/src/main/java/com/fuzamei/service/ValuationAccountingService.java

@@ -8,7 +8,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.fuzamei.constant.BattleResult;
+import com.fuzamei.constant.OperationTypeId;
+import com.fuzamei.constant.Role;
+import com.fuzamei.dao.AttachmentDao;
+import com.fuzamei.dao.ProjectFileDao;
+import com.fuzamei.dao.UserAuthoricationDao;
 import com.fuzamei.dao.ValuationAccountingDao;
+import com.fuzamei.entity.UserDetail;
 import com.fuzamei.entity.ValuationAccount;
 import com.fuzamei.utils.PageDTO;
 
@@ -17,73 +24,24 @@ public class ValuationAccountingService {
 	
 	@Autowired
 	private ValuationAccountingDao valuationAccountingDao;
-
-	private static final int ROW_NUM = 10; // 分页每页显示数据的数量
 	
+	@Autowired
+	private ProjectFileDao projectFileDao;
+	/**
+	 * 
+	* @Title: queryValuationAccountingInformation
+	* @Description: TODO(查看估值核算表的信息,只有管理人和省托管分中心估值核算岗才有权限查看)
+	* @param @param map
+	* @param @return    设定文件
+	* @return PageDTO    返回类型
+	* @author ylx
+	* @date 2017年12月28日 上午11:38:35
+	* @throws
+	 */
 	public PageDTO queryValuationAccountingInformation(Map<String, Object> map) {
-		int page = 1; // 默认页是第一页
-		String fundName="";	//基金名默认为空
-		String battleResult="";	//比对结果默认为空
-		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("fundName")) && map.get("fundName") != null) { // 等于空就直接取空值
-			try {
-				fundName = (String) map.get("fundName");
-			} catch (Exception e) {
-				fundName="";//类型转换异常基金名称还是空字符串
-			}
-		}
-		if (!"".equals(map.get("battleResult")) && map.get("battleResult") != null) { // 等于空就直接取空值
-			try {
-				battleResult = (String) map.get("battleResult");
-			} catch (Exception e) {
-				battleResult="";//类型转换异常比对结果还是空字符串
-			}
-		}
-		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
-			}
-		}
-		Map<String, Object> mapToDao = new LinkedHashMap<String, Object>();				//这个map是去dao层调取数据的
-		mapToDao.put("startPage", (page - 1) * ROW_NUM);
-		mapToDao.put("fundName", fundName);
-		mapToDao.put("battleResult", battleResult);
-		
-		//如果时间顺序错位,要重新进行排位
-		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条,可根据需求修改分页数量
-		
 		PageDTO pageDTO=new PageDTO();
-		
-		List<ValuationAccount> informationList=valuationAccountingDao.queryValuationAccountingInformation(mapToDao);	//从service层中获取分页的对象信息
-		int count=valuationAccountingDao.findAllInformations();	//获取总的信息数量
+		List<ValuationAccount> informationList=valuationAccountingDao.queryValuationAccountingInformation(map);	//从service层中获取分页的对象信息
+		int count=valuationAccountingDao.findAllInformations();													//获取总的信息数量
 		pageDTO.setTotal(count);
 		pageDTO.setRows(informationList);
 		return pageDTO;
@@ -92,7 +50,7 @@ public class ValuationAccountingService {
 	/**
 	 * 
 	* @Title: insertInformationIntoTable
-	* @Description: TODO(以管理员身份将估值核算等数据插入数据库中)
+	* @Description: TODO(以管理员身份首次将估值核算等数据插入数据库中------>首次创建基金id号要生成,基金名,托管资产都要从用户这里获取)
 	* @param @param map    设定文件
 	* @return void    返回类型
 	* @author ylx
@@ -100,79 +58,39 @@ public class ValuationAccountingService {
 	* @throws
 	 */
 	@Transactional(rollbackFor=Exception.class)
-	public void insertInformationIntoTableByAdmin(Map<String, Object> map) {
-		String fundId="";			//基金id号
-		String fundName="";			//基金名称
-		String assets="";			//托管资产名称
-		String url="";					//url路径名称
-		String attachmentName="";		//附件名称
-		if (!"".equals(map.get("fundId")) && map.get("fundId") != null) { // 等于空就直接取空值
-			try {
-				fundId = (String) map.get("fundId");
-			} catch (Exception e) {
-				throw new RuntimeException("fundId类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("项目id号为空");
-		}
-		if (!"".equals(map.get("fundName")) && map.get("fundName") != null) { // 等于空就直接取空值
-			try {
-				fundName = (String) map.get("fundName");
-			} catch (Exception e) {
-				throw new RuntimeException("fundName类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("项目名称为空");
-		}
-		if (!"".equals(map.get("assets")) && map.get("assets") != null) { // 等于空就直接取空值
-			try {
-				assets = (String) map.get("assets");
-			} catch (Exception e) {
-				throw new RuntimeException("assets类型转换异常");
-			}
-		}else{
-			throw new RuntimeException("url路径名称为空");
-		}
-		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("附件名称为空");
-		}
-		
+	public void insertInformationIntoTableByAdminForTheFirstTime(Map<String, Object> map) {
+		long currentTime = System.currentTimeMillis();
+		int attachmentId = (Integer) map.get("attachmentId");
+		UserDetail userDetail = (UserDetail) map.get("userDetail"); 
 		//将数据插入到估值核算表的数据封装到mapToDaoForValuationAccounting
 		Map<String, Object> mapToDaoForValuationAccounting = new LinkedHashMap<String,Object>();
-		mapToDaoForValuationAccounting.put("fundId", fundId);
-		mapToDaoForValuationAccounting.put("fundName", fundName);
-		mapToDaoForValuationAccounting.put("assets", assets);
-		
+		mapToDaoForValuationAccounting.put("fundId", map.get("fundId"));
+		mapToDaoForValuationAccounting.put("fundName", map.get("fundName"));
+		mapToDaoForValuationAccounting.put("assets", map.get("assets"));
 		//管理员估值报表的id,而银行估值报表的id这个时候是没有添加的,也就是表中插入数据的时候,银行估值报表的id先空着
-		mapToDaoForValuationAccounting.put("attachmentId", (Integer)(int)(Math.random()*1000000));		//附件id不能用随机数,这里到时候要改的(这个是管理员估值报表的id)。。。。。。。。。TODO
-		mapToDaoForValuationAccounting.put("updateTime", System.currentTimeMillis());			//上传文件的更新时间为当前时间
-		mapToDaoForValuationAccounting.put("battleResult", "待对账");							//上传文件的hash值到时候要通过对文件进行计算后才能进行数据库的录入(这里先写死)。。。。。。。。TODO
+		mapToDaoForValuationAccounting.put("attachmentId", attachmentId);									//附件id已经写活♥
+		mapToDaoForValuationAccounting.put("updateTime", currentTime);										//上传文件的更新时间为当前时间
+		mapToDaoForValuationAccounting.put("battleResult", BattleResult.TO_BE_MATCHED);						//对账结果为待对账,这里就是一个常量信息♥
 		valuationAccountingDao.insertInformationIntoTableByAdmin(mapToDaoForValuationAccounting);			//将以上的数据直接添加到数据库中【估值核算表】去
 
 		//将附件信息放入到mapToDaoForAttachment并传递到数据库插入
 		Map<String, Object> mapToDaoForAttachment = new LinkedHashMap<String,Object>();
-		mapToDaoForAttachment.put("attachmentId", mapToDaoForValuationAccounting.get("attachmentId"));	//附件表的id直接从之前封装的map中获取即可
-		mapToDaoForAttachment.put("attachmentName", attachmentName);									//附件名称需要录入
-		mapToDaoForAttachment.put("url", url);															//下载文件需要用到的url地址需要录入
-		//用户id到时候再确定,先写死
-		mapToDaoForAttachment.put("userId", 2000000001);												//用户id(这里先写死)。。。。。。。。。。TODO
-		mapToDaoForAttachment.put("addTime", (Long)mapToDaoForValuationAccounting.get("updateTime"));	//这里添加的文件上传时间,和估值核算添加的时间一致
+		mapToDaoForAttachment.put("attachmentId", attachmentId);										//附件id已经写活♥
+		mapToDaoForAttachment.put("attachmentName", map.get("attachmentName"));							//附件名称需要录入
+		mapToDaoForAttachment.put("url", map.get("url"));												//下载文件需要用到的url地址需要录入
+		mapToDaoForAttachment.put("userId", map.get("userId"));											//用户id♥
+		mapToDaoForAttachment.put("addTime", currentTime);												//这里添加的文件上传时间,和估值核算添加的时间一致
 		valuationAccountingDao.insertInformationToAttachment(mapToDaoForValuationAccounting);
+		
+		//此外,还要将业务申报的这个操作信息插入到操作记录表中【操作记录表】
+		Map<String, Object> mapToOperationHistory = new LinkedHashMap<String,Object>();
+		mapToOperationHistory.put("operatorTypeId", OperationTypeId.UPLOAD_VALUATION_CHECK);	//上传估值核算表为1010
+		mapToOperationHistory.put("operatorAccount", userDetail.getAccount());					//操作账号通过userDetail中获取
+		mapToOperationHistory.put("operatorRole", Role.ADMIN);									//创建这个操作的角色只能是管理人
+		mapToOperationHistory.put("operatorPerson", userDetail.getPerson_name());				//操作人通过userDetail中获取
+		mapToOperationHistory.put("operatorTime", currentTime);									//操作时间为当前操作时间
+		mapToOperationHistory.put("hash", "来自前端token计算");									//如何计算操作的hash值?(按照上传的项目文件的hash值算)=====>>待定TODO
+		projectFileDao.insertOperationHistoryInformationToDao(mapToOperationHistory);   		//将操作记录信息插入到操作记录表中
 	}
 
 	/**
@@ -277,9 +195,91 @@ public class ValuationAccountingService {
 		mapToOperationHistory.put("operatorTime", mapToDaoForValuationAccounting.get("updateTime"));			//操作时间为当前操作时间
 		mapToOperationHistory.put("hash", "to be calculated from operation");			//如何计算操作的hash值????
 		valuationAccountingDao.insertOperationHistoryInformationToDao(mapToOperationHistory);//将操作记录信息插入到操作记录表中
-		
-		
-		
 	}
 
+	
+	/**
+	 * 
+	* @Title: checkoutDownloadInformation
+	* @Description: TODO(去数据库调取下载提示框的信息)
+	* @param @param fundId
+	* @param @return    设定文件
+	* @return Map<String,Object>    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午1:59:58
+	* @throws
+	 */
+	public List<ValuationAccount> checkoutDownloadInformation(int fundId) {
+		List<ValuationAccount> listToClient = valuationAccountingDao.checkoutDownloadInformation(fundId);
+		if(listToClient==null||listToClient.isEmpty()){
+			throw new RuntimeException("查无此信息");
+		}
+		return listToClient;
+	}
+
+	/**
+	 * 
+	* @Title: generateFundId
+	* @Description: TODO(用于给前端返回一个fundId号,而且还不能和数据库中已有的id号重复)
+	* @param @return    设定文件
+	* @return Map<String,Object>    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午3:45:12
+	* @throws
+	 */
+	public Map<String, Object> generateFundId() {
+		int same = 0;
+		Integer fundId = null;
+		//如果有重复的继续查,直到查不出重复的fundId号为止
+		while(same > 0){
+			fundId=(int)(Math.random()*1000000000);								//=========================>>>产生基金id号的机制要改的TODO
+			same = valuationAccountingDao.queryIfHasTheSameFundId(fundId);
+		}
+		Map<String, Object> mapToClient = new LinkedHashMap<>();
+		mapToClient.put("fundId", fundId);
+		return mapToClient;
+	}
+	
+	/**
+	 * 
+	* @Title: checkIfHasTheSameFundId
+	* @Description: TODO(验证基金id号是不是已经存在,如果已经存在直接报错)
+	* @param @param fundId    设定文件
+	* @return void    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午5:18:55
+	* @throws
+	 */
+	public void checkIfHasTheSameFundId(int fundId){
+		int same = valuationAccountingDao.queryIfHasTheSameFundId(fundId);
+		if(same >0){
+			throw new RuntimeException("该信息已经存在");
+		}
+	}
+
+	/**
+	 * 
+	* @Title: checkIfFundExists
+	* @Description: TODO(验证该基金是否存在,并返回这个基金的对账结果)
+	* @param @param fundId
+	* @param @param fundName
+	* @param @param     设定文件
+	* @return void    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午6:22:16
+	* @throws
+	 */
+	public ValuationAccount checkIfFundExists(Integer fundId, String fundName) {
+		ValuationAccount valuationAccount = valuationAccountingDao.checkIfFundExists(fundId,fundName);
+		if(valuationAccount == null){
+			throw new RuntimeException("该信息不存在");
+		}
+		return valuationAccount;
+	}
+	
+	
+	
+	
+	
+
 }

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

@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSON;
 import com.fuzamei.entity.OperationHistoryBO;
 import com.fuzamei.entity.UserDetail;
 import com.fuzamei.service.OperationHistoryService;
+import com.fuzamei.service.UserAuthoricationService;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.PageDTO;
 import com.fuzamei.utils.StringUtil;
@@ -33,7 +34,6 @@ public class OperationHistoryAction {
 	@Autowired
 	private OperationHistoryService operationHistoryService;
 	
-	
 	private static final int ROW_NUM = 10; // 分页每页显示数据的数量
 	/**
 	 * 
@@ -57,12 +57,12 @@ 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("查询操作记录信息....");
+			@SuppressWarnings("unchecked")
 			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); // 默认页是第一页

+ 27 - 19
ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ProjectFileAction.java

@@ -27,9 +27,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.alibaba.fastjson.JSON;
+import com.fuzamei.constant.HintMSG;
 import com.fuzamei.constant.Role;
 import com.fuzamei.entity.UserDetail;
 import com.fuzamei.service.ProjectFileService;
+import com.fuzamei.service.UserAuthoricationService;
 import com.fuzamei.utils.HashXiZhiUtil;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.PageDTO;
@@ -41,6 +43,9 @@ public class ProjectFileAction {
 
 	@Autowired
 	private ProjectFileService projectFileService;
+	
+	@Autowired
+	private UserAuthoricationService userAuthoricationService;
 
 	private static final int ROW_NUM = 10; // 分页每页显示数据的数量(固定10条数据)
 	
@@ -73,7 +78,7 @@ public class ProjectFileAction {
 			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); // 默认页数是第一页
+			int page = ValidationUtil.checkMinAndAssignInt(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最大值
@@ -90,9 +95,9 @@ public class ProjectFileAction {
 			}
 			mapToService.put("rowNum", ROW_NUM); // 默认每页显示数据是10条,可根据需求修改分页数量
 			PageDTO pageDto = projectFileService.queryProjectFileInformation(mapToService); // 将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
-			return JSONUtil.getJsonMap(200, true, "查询成功", pageDto);
+			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "查询失败:"+e.getMessage(), null);
+			return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
 		}
 	}
 	
@@ -128,9 +133,9 @@ public class ProjectFileAction {
 			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对象直接返回给前端
+			return JSONUtil.getJsonMap(200, true, HintMSG.CHECK_SUCCESS, mapFromService); //将从service返回回来的map对象通过map对象直接返回给前端
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "查询失败"+e.getMessage(), null); 
+			return JSONUtil.getJsonMap(500, false, HintMSG.CHECK_FAIL+":"+e.getMessage(), null); 
 		}
 	}
 	
@@ -151,11 +156,11 @@ public class ProjectFileAction {
 	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,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);//查看用户是否为空及是否有权限下载项目文档文件
+			userAuthoricationService.checkUserAuthority(userId,Role.SUPERVISION_AGENCY,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);//查看用户是否为空及是否有权限下载项目文档文件
 			String fileName = request.getServletContext().getRealPath("")+url;  		//SP是系统分隔符
 			//如果文件不存在直接抛出异常
 			if(!new File(fileName).exists()){
-				throw new RuntimeException("文件不存在");
+				throw new RuntimeException(HintMSG.FILE_NOT_FOUND);
 			}
 			InputStream bis = new BufferedInputStream(new FileInputStream(new File(fileName)));  
 			String filename = url.substring(url.lastIndexOf("/")+1);  //截取文件名
@@ -170,9 +175,9 @@ public class ProjectFileAction {
 			}  
 			out.close();
 			bis.close();
-			return JSONUtil.getJsonMap(200, true, "下载成功",null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(200, true, HintMSG.DOWNLOAD_SUCCESS,null); //返回给前端一个map进行前段提示
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "下载出现异常:"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(500, false, HintMSG.DOWNLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 		}
 	}
 	
@@ -198,16 +203,16 @@ public class ProjectFileAction {
 	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,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);		//该权限只有	【省分行托管分中心档案保管岗】才能操作
-			Integer projectId = ValidationUtil.checkAndAssignDefaultInt(map.get("projectId"),-1);	//默认项目编号为-1,就是让你查不到
-			String projectName=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("projectName"));		//默认项目名称为空值
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));									//userId只要是一个int类型即可
+			userAuthoricationService.checkUserAuthority(userId,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);				//该权限只有	【省分行托管分中心档案保管岗】才能操作
+			Integer projectId = ValidationUtil.checkAndAssignDefaultInt(map.get("projectId"),-1);				//默认项目编号为-1,就是让你查不到
+			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对象直接返回给前端
+			return JSONUtil.getJsonMap(200, true, HintMSG.CHECK_SUCCESS, mapToClient); 										//将从service返回回来的map对象通过map对象直接返回给前端
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "查看出现异常:"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(500, false, HintMSG.CHECK_FAIL+":"+e.getMessage(),null); 							//返回给前端一个map进行前段提示
 		}
 	}
 	
@@ -237,10 +242,13 @@ public class ProjectFileAction {
 									HttpServletRequest request) {
 		try {
 			int userId=ValidationUtil.checkAndAssignInt(uId);
-			UserDetail userDetail = projectFileService.checkUserAuthority(userId,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);//查看用户是否为空及是否有权限下载项目文档文件
+			UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId,Role.ARCHIVE_KEEPING_POS_OF_PBBTBC);//查看用户是否为空及是否有权限下载项目文档文件
 			String projectId = ValidationUtil.checkBlankAndAssignString(pId);				//校验projectId并赋值
 			String projectName = ValidationUtil.checkBlankAndAssignString(pName);			//校验projectName并赋值
-			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符,path是存放上传文件的父类文件夹绝对路径	
+			if(file.isEmpty()){
+				throw new RuntimeException(HintMSG.FILE_CANT_BE_NULL);						//校验上传的文件是否为空
+			}
+			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符,path是存放上传文件的父类文件夹绝对路径====>>这个路径要改TODO	
 			File dir=new File(path);
 			if(!dir.exists()){
 				dir.mkdirs();
@@ -258,10 +266,10 @@ public class ProjectFileAction {
 			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进行前段提示
+			Map<String, Object> mapResult = JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,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, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 			return mapResult;
 		}
 	}

+ 218 - 44
ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ValuationAccountingAction.java

@@ -8,6 +8,7 @@ import java.io.InputStream;
 import java.net.URLEncoder;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -23,10 +24,19 @@ 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.constant.BattleResult;
+import com.fuzamei.constant.HintMSG;
+import com.fuzamei.constant.Role;
+import com.fuzamei.entity.UserDetail;
+import com.fuzamei.entity.ValuationAccount;
+import com.fuzamei.service.AttachmentService;
+import com.fuzamei.service.UserAuthoricationService;
 import com.fuzamei.service.ValuationAccountingService;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.MapUtil;
 import com.fuzamei.utils.PageDTO;
+import com.fuzamei.utils.ValidationUtil;
 
 /**
  * 估值核算模块实现
@@ -40,14 +50,28 @@ public class ValuationAccountingAction {
 	@Autowired
 	private ValuationAccountingService valuationAccountingService;
 	
+	@Autowired
+	private UserAuthoricationService userAuthoricationService;
+	
+	@Autowired
+	private AttachmentService attachmentService;
+	
 	private static final String SP = File.separator;	//系统分隔符,随操作系统而决定
 	
+	private static final int ROW_NUM = 10; // 分页每页显示数据的数量
 	/**
 	 * 
 	* @Title: queryOperationHistoryInformation
 	* @Description: TODO(估值核算的查询结果,包括所有的查询条件也包括进去了)
-	* @param @param data
-	* @param @return    设定文件
+	* 				前端传过来的json格式为:
+	* 				{
+	* 					"userId":"xxx",
+	* 					"page":"1",
+	* 					"fundName":"",
+	* 					"battleResult":"",
+	* 					"startTime":"",
+	* 					"endTime":""
+	* 				}
 	* @return Map<String,Object>    返回类型
 	* @author ylx
 	* @date 2017年12月18日 下午3:17:30
@@ -56,22 +80,110 @@ public class ValuationAccountingAction {
 	@RequestMapping(value="/queryValuationAccountingInformation",method=RequestMethod.POST)
 	@ResponseBody
 	public Map<String,Object> queryOperationHistoryInformation(@RequestBody String data){
-		
-		System.out.println("查询估值核算数据");
-		
-		Map<String, Object> map = JSONUtil.jsonToMap(data);
-		
-		PageDTO pageDto = valuationAccountingService.queryValuationAccountingInformation(map);
-		
-		return JSONUtil.getJsonMap(200, true, "查询成功", pageDto);
+		try {
+			System.out.println("查询估值核算数据");
+			@SuppressWarnings("unchecked")
+			Map<String, Object> map = JSON.parseObject(data, Map.class);
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));										//userId只要是一个int类型即可
+			userAuthoricationService.checkUserAuthority(userId,Role.ADMIN,Role.ACCOUNTING_POS_OF_TBC);				//查看用户非空和权限
+			int page = ValidationUtil.checkMinAndAssignInt(map.get("page"), 1); 									// 默认页是第一页
+			String fundName=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("fundName"));			//基金名默认为空
+			String battleResult=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("battleResult"));	//比对结果默认为空
+			long startTime = ValidationUtil.checkAndAssignDefaultLong(map.get("startTime"), 0L); 					//开始时间默认0
+			long endTime = ValidationUtil.checkAndAssignDefaultLong(map.get("endTime"), Long.MAX_VALUE); 			//结束时间默认Long最大值
+			Map<String, Object> mapToService = new LinkedHashMap<String, Object>();									//这个map是去service层调取数据的
+			mapToService.put("userId", userId);
+			mapToService.put("startPage", (page - 1) * ROW_NUM);
+			mapToService.put("fundName", fundName);
+			mapToService.put("battleResult", battleResult);
+			//如果时间顺序错位,要重新进行排位
+			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 = valuationAccountingService.queryValuationAccountingInformation(mapToService);
+			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
+		}
 	}
 	
+	
+	/**
+	 * 
+	* @Title: queryOperationHistoryInformation
+	* @Description: TODO(查看估值核算基金的下载信息的小弹框)
+	* @param @param data
+	* 				前端传过来的json格式
+	* 				{
+	* 					userId:"xxx",
+	* 					fundId:""
+	* 				}
+	* @param @return    设定文件
+	* @return Map<String,Object>    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午1:48:43
+	* @throws
+	 */
+	@RequestMapping(value="/checkoutDownloadInformation",method=RequestMethod.POST)
+	@ResponseBody
+	public Map<String,Object> checkoutDownloadInformation(@RequestBody String data){
+		try {
+			@SuppressWarnings("unchecked")
+			Map<String, Object> map = JSON.parseObject(data, Map.class);
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));										//userId只要是一个int类型即可
+			userAuthoricationService.checkUserAuthority(userId,Role.ADMIN,Role.ACCOUNTING_POS_OF_TBC);				//查看用户非空和权限
+			int fundId = ValidationUtil.checkAndAssignInt(map.get("fundId"));										//fundId只要是一个int类型即可
+			List<ValuationAccount> listToClient = valuationAccountingService.checkoutDownloadInformation(fundId);	//这个map是去service层调取数据的
+			return JSONUtil.getJsonMap(200, true, HintMSG.CHECK_SUCCESS, listToClient);
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, HintMSG.CHECK_FAIL+":"+e.getMessage(), null);
+		}
+	}
+	
+	
+	/**
+	 * 
+	* @Title: checkoutDownloadInformation
+	* @Description: TODO(管理人首次上传估值报表弹出的界面需要显示的ID号)
+	* 				前端传过来的json数据格式
+	* 				{
+	* 					"userId":"xxx"
+	* 				}
+	* @param @return    返回一个fundId的值用于弹框中首次创建基金id的回显
+	* @return Map<String,Object>    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午3:39:18
+	* @throws
+	 */
+	@RequestMapping(value="/fistUploadFundDataByAdmin",method=RequestMethod.POST)
+	@ResponseBody
+	public Map<String,Object> fistUploadFundDataByAdmin(@RequestBody String data){
+		try {
+			@SuppressWarnings("unchecked")
+			Map<String, Object> map = JSON.parseObject(data, Map.class);
+			int userId = ValidationUtil.checkAndAssignInt(map.get("userId"));										//userId只要是一个int类型即可
+			userAuthoricationService.checkUserAuthority(userId,Role.ADMIN);											//查看用户非空和权限
+			Map<String, Object> mapToClient = valuationAccountingService.generateFundId();							//这个map是去service层调fundId的
+			return JSONUtil.getJsonMap(200, true, HintMSG.CHECK_SUCCESS, mapToClient);
+		} catch (Exception e) {
+			return JSONUtil.getJsonMap(500, false, HintMSG.CHECK_FAIL+":"+e.getMessage(), null);
+		}
+	}
+	
+	
+	
 	/**
 	 * 
 	* @Title: download
 	* @Description: TODO(估值核算界面,下载功能实现)
-	* @param @param request
-	* @param @param response
+	* 				前端通过get或post发来请求
+	* 				url:链接地址
+	* 				userId:用户id号
 	* @param @param url
 	* @param @return    设定文件
 	* @return Map<String,Object>    返回类型
@@ -81,9 +193,18 @@ public class ValuationAccountingAction {
 	 */
 	@RequestMapping(value="/downloadValuationPOI")
 	@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 uId) {
 		try {
+			int userId=ValidationUtil.checkAndAssignInt(uId);
+			userAuthoricationService.checkUserAuthority(userId,Role.ADMIN,Role.ACCOUNTING_POS_OF_TBC);	//查看用户非空和权限(管理员和核算岗都能进行下载)
+			url=ValidationUtil.checkBlankAndAssignString(url);							//对传过来的url进行非空校验
 			String fileName = request.getServletContext().getRealPath("")+url;  		//SP是系统分隔符
+			//如果文件不存在直接抛出异常
+			if(!new File(fileName).exists()){
+				throw new RuntimeException(HintMSG.FILE_NOT_FOUND);
+			}
 			InputStream bis = new BufferedInputStream(new FileInputStream(new File(fileName)));  
 			String filename = url.substring(url.lastIndexOf("/")+1);  //截取文件名
 			filename = URLEncoder.encode(filename,"UTF-8");
@@ -97,9 +218,9 @@ public class ValuationAccountingAction {
 			}  
 			out.close();
 			bis.close();
-			return JSONUtil.getJsonMap(200, true, "下载成功",null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(200, true, HintMSG.DOWNLOAD_SUCCESS,null); //返回给前端一个map进行前段提示
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "下载出现异常:"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(500, false, HintMSG.DOWNLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 		}
 	}
 	
@@ -108,11 +229,12 @@ public class ValuationAccountingAction {
 	* @Title: upload
 	* @Description: TODO(实现管理员估值核算的报表文件上传功能---------->>暂时按照一次上传一个文件进行实现)
 	* 
-	* 如果是管理岗的人员进行上传,则是创建一条新的数据进数据库,同时在附件表中插入一条新的数据
-	* 
-	* @param @param file
-	* @param @param request
-	* @param @param fundId 			基金id号,前端随机生成?????还是说后台生成????TODO
+	* 因为是首次创建,管理岗的人员进行上传,则是创建一条新的数据进数据库,同时在附件表中插入一条新的数据,同时还要在操作记录也要插入一条操作记录,操作记录hash以这个文件的hash为准
+	* @ Attention: 首次上传,所以大部分的信息可以写死
+	* 				首次创建基金id号要生成,基金名,托管资产都要从用户这里获取
+	* 				传过来的参数以表单形式提交
+	* @param @param userId			用户id号
+	* @param @param fundId 			基金id号,前端随机生成?????还是说后台生成????================================>暂时通过打开估值核算弹框自动生成TODO
 	* @param @param fundName		基金名称,客户端手动输入生成并传输过来
 	* @param @param assets			托管资产,客户端手动输入生成并传输过来
 	* @param @return    设定文件
@@ -121,34 +243,51 @@ public class ValuationAccountingAction {
 	* @date 2017年12月18日 下午5:29:38
 	* @throws
 	 */
-	@RequestMapping(value="/uploadValuationPOIByAdmin",method=RequestMethod.POST)
+	@RequestMapping(value="/uploadValuationPOIByAdminForTheFirstTime",method=RequestMethod.POST)
 	@ResponseBody
-	public Map<String, Object> uploadValuationPOIByAdmin(@RequestParam("file") MultipartFile file,HttpServletRequest request,@RequestParam("fundId") String fundId,@RequestParam("fundName") String fundName, @RequestParam("assets") String assets ) {
+	public Map<String, Object> uploadValuationPOIByAdmin(@RequestParam("file") MultipartFile file,HttpServletRequest request,
+														 @RequestParam("fundId") String fId,
+														 @RequestParam("fundName") String fName, 
+														 @RequestParam("assets") String ass,
+														 @RequestParam("userId") Object uId) {
 		try {
+			int userId=ValidationUtil.checkAndAssignInt(uId);
+			UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId,Role.ADMIN);	//查看用户非空和权限(管理员创建并上传的权限)
+			Integer fundId=ValidationUtil.checkAndAssignInt(fId);							//基金id号
+			valuationAccountingService.checkIfHasTheSameFundId(fundId);						//对传过来的基金id进行查重校验
+			String fundName=ValidationUtil.checkBlankAndAssignString(fName);				//基金名称===============================>>基金名要不要查重?TODO
+			String assets=ValidationUtil.checkBlankAndAssignString(ass);					//托管资产名称============================>>托管资产要不要查重?TODO
+			Integer attachmentId = attachmentService.generateAtachmentId();					//生成一个不重复的附件Id号==================>>生成id号的机制待定TODO
+			if(file.isEmpty()){
+				throw new RuntimeException("上传文件不能为空");
+			}
 			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符	
 			File dir=new File(path);
 			if(!dir.exists()){
 				dir.mkdirs();
 			}
-			
 			String filename = file.getOriginalFilename();
+			String url = "/content/"+ValidationUtil.checkBlankAndAssignString(filename);	//url路径名称被赋值之前先进行filename的校验
+			String attachmentName = filename;												//附件名称,已经校验过,不需要再进行校验了
 			String pathFile=path+SP+filename;
 			File newFile=new File(pathFile);
-			file.transferTo(newFile);
-			
-			Map<String, Object> map =new LinkedHashMap<String, Object>();
-			map.put("fundId", fundId);
-			map.put("fundName", fundName);
-			map.put("assets", assets);
-			map.put("url", "/content/"+filename);		//将文件下载路径url通过map传到service层进行校验
-			map.put("attachmentName", filename);			//将文件以附件名的形式通过map传递到service层中进行校验
+			file.transferTo(newFile);														//此时文件已经上传成功---->upload file success
 			
+			Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
+			mapToService.put("userId", userId);												//用户id号
+			mapToService.put("userDetail", userDetail);										//用户详细信息封装入map
+			mapToService.put("fundId", fundId);
+			mapToService.put("fundName", fundName);
+			mapToService.put("assets", assets);
+			mapToService.put("url", url);													//将文件下载路径url通过map传到service层进行校验
+			mapToService.put("attachmentName", attachmentName);								//将文件以附件名的形式通过map传递到service层中进行校验
+			mapToService.put("attachmentId", attachmentId);									//附件id号封装好
 			//这里是以管理岗的身份进行插入的,注意银行的估值报表暂时先不插入数据
-			valuationAccountingService.insertInformationIntoTableByAdmin(map);		//将获取到的数据插入到表中
+			valuationAccountingService.insertInformationIntoTableByAdminForTheFirstTime(mapToService);		//将获取到的数据插入到表中
 			
-			return JSONUtil.getJsonMap(200, true, "上传成功",null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个map进行前段提示
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "上传出现异常"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 		}
 	}
 	
@@ -157,20 +296,58 @@ public class ValuationAccountingAction {
 	* @Title: upload
 	* @Description: TODO(实现银行估值核算的报表文件上传功能---------->>暂时按照一次上传一个文件进行实现)
 	* @param @param file
-	* @param @param request
 	* @param @param fundId
 	* @param @param fundName
-	* @param @param assets
-	* @param @return    设定文件
+	* @param @param userId
+	* @param @return    这里上传人有可能是银行也有可能是管理岗的人,这里要进行校验
 	* @return Map<String,Object>    返回类型
 	* @author ylx
 	* @date 2017年12月18日 下午8:17:47
 	* @throws
 	 */
-	@RequestMapping(value="/uploadValuationPOIByBank",method=RequestMethod.POST)
+	@RequestMapping(value="/uploadValuationPOIByBankOrByAdmin",method=RequestMethod.POST)
 	@ResponseBody
-	public Map<String, Object> uploadValuationPOIByBank(@RequestParam("file") MultipartFile file,HttpServletRequest request,@RequestParam("fundId") String fundId,@RequestParam("fundName") String fundName, @RequestParam("assets") String assets ) {
+	public Map<String, Object> uploadValuationPOIByBank(@RequestParam("file") MultipartFile file,HttpServletRequest request,
+														@RequestParam("fundId") String fId,
+														@RequestParam("fundName") String fName, 
+														@RequestParam("userId") Object uId) {
 		try {
+			if(file.isEmpty()){
+				throw new RuntimeException("上传文件不能为空");
+			}
+			int userId=ValidationUtil.checkAndAssignInt(uId);
+			UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId,Role.ADMIN,Role.ACCOUNTING_POS_OF_TBC);//查看用户非空和权限(管理员创建并上传的权限)
+			Integer fundId=ValidationUtil.checkAndAssignInt(fId);									//基金id号
+			String fundName=ValidationUtil.checkBlankAndAssignString(fName);						//基金名称
+			ValuationAccount valuationAccount = valuationAccountingService.checkIfFundExists(fundId,fundName); 	//对传过来的基金id进行检测是否存在,并赋值对账结果,不存在就报错(因为这个时候基金信息已经存在)
+			//获得对账结果
+			String battleResult = valuationAccount.getBattle_result();
+			List<String> roleList=userDetail.getRole_name();
+			
+			//已经对账结束,无法继续上传文件
+			if(BattleResult.CONSISTENT.equals(battleResult)){
+				throw new RuntimeException("对账结果一致,无法继续上传文件");
+			}
+			
+			//判断是否是管理岗
+			if(roleList.contains(Role.ADMIN)){
+				if(BattleResult.TO_BE_MATCHED.equals(battleResult)){
+					throw new RuntimeException("待对账中无法重复上传");
+				}
+				//接下来肯定是对账结果不一致,说明可以上传文件===================>>待做TODO
+				
+			}
+			
+			//接下来的业务肯定是银行
+			
+			
+			
+			
+			
+			Integer attachmentId = attachmentService.generateAtachmentId();					//生成一个不重复的附件Id号==================>>生成id号的机制待定TODO
+			
+			
+			
 			String path = request.getServletContext().getRealPath("")+SP+"content";			//SP是系统分隔符	
 			File dir=new File(path);
 			if(!dir.exists()){
@@ -184,18 +361,15 @@ public class ValuationAccountingAction {
 			Map<String, Object> map =new LinkedHashMap<String, Object>();
 			map.put("fundId", fundId);
 			map.put("fundName", fundName);
-			map.put("assets", assets);
 			map.put("url", "/content/"+filename);		//将文件下载路径url通过map传到service层进行校验
 			map.put("attachmentName", filename);			//将文件以附件名的形式通过map传递到service层中进行校验
 			
 			//这里是以银行的身份将数据进行更新
 			valuationAccountingService.updateInformationByBank(map);		//将获取到的数据更新到已有的估值核算表中,这个表是由管理岗创建的
-			
-			return JSONUtil.getJsonMap(200, true, "上传成功",null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个map进行前段提示
 		} catch (Exception e) {
-			return JSONUtil.getJsonMap(500, false, "上传出现异常"+e.getMessage(),null); //返回给前端一个map进行前段提示
+			return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 		}
 	}
 	
-	
 }