ylx 7 years ago
parent
commit
19b948b2af

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

@@ -63,4 +63,8 @@ public class ValuationAccountingDao {
 		valuationAccountingMapper.updateAttachmentInformationByBank(map);
 	}
 
+	public int queryIfHasTheSameFundName(String fundName) {
+		return valuationAccountingMapper.queryIfHasTheSameFundName(fundName);
+	}
+
 }

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

@@ -163,6 +163,13 @@
 	<select id="queryIfHasTheSameFundId" resultType="int">
 		select count(*) from valuation_accounting where fund_id=#{fundId}
 	</select>
+
+	<!-- 对是否有重复的fundId进行查询并返回重复结果 -->
+	<select id="queryIfHasTheSameFundName" resultType="int">
+		select count(*) from valuation_accounting where fund_name=#{fundName}
+	</select>
+	
+	
 	
 	<!-- 对是否有存在基金数据进行查询并返回查询到的结果 -->
 	<select id="checkIfFundExists" resultType="com.fuzamei.entity.ValuationAccount">
@@ -184,6 +191,7 @@
 				va.fund_name,
 				va.assets_under_custody,
 				att.attachment_name,
+				va.custodian_valuation_id,
 				va.bank_valuation_id,
 				va.battle_result,
 				att.url,

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

@@ -33,4 +33,6 @@ public interface ValuationAccountingMapper {
 
 	void updateAttachmentInformationByBank(Map<String, Object> map);
 
+	int queryIfHasTheSameFundName(String fundName);
+
 }

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

@@ -15,7 +15,7 @@ public class AttachmentService {
 	private AttachmentDao attachmentDao;
 	
 	public int generateAtachmentId(){
-		int same = 0;
+		int same = -1;
 		Integer attachmentId = null;
 		//如果有重复的继续查,直到查不出重复的fundId号为止
 		while(same != 0){

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

@@ -80,7 +80,7 @@ public class ValuationAccountingService {
 		mapToDaoForAttachment.put("url", map.get("url"));												//下载文件需要用到的url地址需要录入
 		mapToDaoForAttachment.put("userId", map.get("userId"));											//用户id♥
 		mapToDaoForAttachment.put("addTime", currentTime);												//这里添加的文件上传时间,和估值核算添加的时间一致
-		valuationAccountingDao.insertInformationToAttachment(mapToDaoForValuationAccounting);
+		valuationAccountingDao.insertInformationToAttachment(mapToDaoForAttachment);
 		
 		//此外,还要将业务申报的这个操作信息插入到操作记录表中【操作记录表】
 		Map<String, Object> mapToOperationHistory = new LinkedHashMap<String,Object>();
@@ -286,6 +286,23 @@ public class ValuationAccountingService {
 		return valuationAccount;
 	}
 
+	/**
+	 * 
+	* @Title: checkIfHasTheSameFundId
+	* @Description: TODO(验证基金名是不是已经存在,如果已经存在直接报错)
+	* @param @param fundId    设定文件
+	* @return void    返回类型
+	* @author ylx
+	* @date 2017年12月28日 下午5:18:55
+	* @throws
+	 */
+	public void checkIfHasTheSameFundName(String fundName) {
+		int same = valuationAccountingDao.queryIfHasTheSameFundName(fundName);
+		if(same >0){
+			throw new RuntimeException("该信息已经存在");
+		}
+	}
+
 	
 	
 	

+ 20 - 9
ccb_fund_trusteeship/src/main/java/com/fuzamei/web/ValuationAccountingAction.java

@@ -36,6 +36,7 @@ import com.fuzamei.service.ValuationAccountingService;
 import com.fuzamei.utils.JSONUtil;
 import com.fuzamei.utils.MapUtil;
 import com.fuzamei.utils.PageDTO;
+import com.fuzamei.utils.RelativePathUtil;
 import com.fuzamei.utils.ValidationUtil;
 
 /**
@@ -255,17 +256,23 @@ public class ValuationAccountingAction {
 														 @RequestParam("assets") String ass,
 														 @RequestParam("userId") Object uId) {
 		try {
+			if(file.isEmpty()){
+				throw new RuntimeException("上传文件不能为空");
+			}
 			int userId=ValidationUtil.checkAndAssignInt(uId);
 			UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId,Role.ADMIN);	//查看用户非空和权限(管理员创建并上传的权限)
 			Integer fundId=ValidationUtil.checkAndAssignInt(fId);							//基金id号
-			valuationAccountingService.checkIfHasTheSameFundId(fundId);						//对传过来的基金id进行查重校验
+			valuationAccountingService.checkIfHasTheSameFundId(fundId);						//对传过来的基金id(fundId)进行查重校验
 			String fundName=ValidationUtil.checkBlankAndAssignString(fName);				//基金名称===============================>>基金名要不要查重?TODO
+			valuationAccountingService.checkIfHasTheSameFundName(fundName);					//对传过来的基金名(fundName)进行查重校验
 			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是系统分隔符	
+			
+			String path = request.getServletContext().getRealPath("");							//上传文件顶级父类的绝对路径============================>>路径机制待定TODO	
+			String relativePath = RelativePathUtil.formatPath("/"+userId,"");					//生成默认的相对路径格式================================>>路径机制待定TODO
+			
+			
+			
 			File dir=new File(path);
 			if(!dir.exists()){
 				dir.mkdirs();
@@ -275,7 +282,7 @@ public class ValuationAccountingAction {
 			String attachmentName = filename;												//附件名称,已经校验过,不需要再进行校验了
 			String pathFile=path+SP+filename;
 			File newFile=new File(pathFile);
-			file.transferTo(newFile);														//此时文件已经上传成功---->upload file success
+			
 			
 			Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
 			mapToService.put("userId", userId);												//用户id号
@@ -289,6 +296,9 @@ public class ValuationAccountingAction {
 			//这里是以管理岗的身份进行插入的,注意银行的估值报表暂时先不插入数据
 			valuationAccountingService.insertInformationIntoTableByAdminForTheFirstTime(mapToService);		//将获取到的数据插入到表中
 			
+			//文件最后上传到服务器
+			file.transferTo(newFile);														//此时文件已经上传成功---->upload file success
+			
 			return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个map进行前段提示
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
@@ -392,7 +402,7 @@ public class ValuationAccountingAction {
 				//待审核的状态说明文件是一个新的文件上传上去
 				
 				//先获取管理员之前上传的文件
-				String custodianOldFilePath = path+valuationAccount.getUrl_of_custodian();
+				String custodianOldFilePath = path+SP+valuationAccount.getUrl_of_custodian();
 				//核查文件是否还在
 				File oldFile = new File(custodianOldFilePath);
 				if(!oldFile.exists()){
@@ -486,10 +496,11 @@ public class ValuationAccountingAction {
 			Map map= JSON.parseObject(data, Map.class);
 			int userId=ValidationUtil.checkAndAssignInt(map.get("userId"));
 			UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId,Role.ADMIN,Role.ACCOUNTING_POS_OF_TBC);	//查看用户非空和权限(管理员创建并上传的权限)
-			return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,userDetail); //返回给前端一个成功提示
+			ValuationAccount valuationAccount = valuationAccountingService.checkIfFundExists((Integer)map.get("fundId"), (String)map.get("fundName"));
+			return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,valuationAccount); //返回给前端一个成功提示
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
 		}
 	}
-
+	
 }