|
@@ -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,20 @@ 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.RelativePathUtil;
|
|
|
+import com.fuzamei.utils.ValidationUtil;
|
|
|
|
|
|
/**
|
|
|
* 估值核算模块实现
|
|
@@ -34,20 +45,34 @@ import com.fuzamei.utils.PageDTO;
|
|
|
*
|
|
|
*/
|
|
|
@Controller
|
|
|
-@RequestMapping("valuation_accounting")
|
|
|
+@RequestMapping("/valuation_accounting")
|
|
|
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 +81,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 +194,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 +219,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,47 +230,78 @@ public class ValuationAccountingAction {
|
|
|
* @Title: upload
|
|
|
* @Description: TODO(实现管理员估值核算的报表文件上传功能---------->>暂时按照一次上传一个文件进行实现)
|
|
|
*
|
|
|
- * 如果是管理岗的人员进行上传,则是创建一条新的数据进数据库,同时在附件表中插入一条新的数据
|
|
|
+ * 因为是首次创建,管理岗的人员进行上传,则是创建一条新的数据进数据库,同时在附件表中插入一条新的数据,同时还要在操作记录也要插入一条操作记录,操作记录hash以这个文件的hash为准
|
|
|
+ * @ Attention: 首次上传,所以大部分的信息可以写死
|
|
|
+ * 首次创建基金id号要生成,基金名,托管资产都要从用户这里获取
|
|
|
+ * 传过来的参数以表单形式提交
|
|
|
*
|
|
|
- * @param @param file
|
|
|
- * @param @param request
|
|
|
- * @param @param fundId 基金id号,前端随机生成?????还是说后台生成????TODO
|
|
|
+ *
|
|
|
+ * @param @param userId 用户id号
|
|
|
+ * @param @param fundId 基金id号,前端随机生成?????还是说后台生成????================================>暂时通过打开估值核算弹框自动生成TODO
|
|
|
* @param @param fundName 基金名称,客户端手动输入生成并传输过来
|
|
|
* @param @param assets 托管资产,客户端手动输入生成并传输过来
|
|
|
+ *
|
|
|
+ *
|
|
|
* @param @return 设定文件
|
|
|
* @return Map<String,Object> 返回类型
|
|
|
* @author ylx
|
|
|
* @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 {
|
|
|
- String path = request.getServletContext().getRealPath("")+SP+"content"; //SP是系统分隔符
|
|
|
+ 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(fundId)进行查重校验
|
|
|
+ String fundName=ValidationUtil.checkBlankAndAssignString(fName); //基金名称===============================>>基金名要不要查重?TODO
|
|
|
+ valuationAccountingService.checkIfHasTheSameFundName(fundName); //对传过来的基金名(fundName)进行查重校验
|
|
|
+ String assets=ValidationUtil.checkBlankAndAssignString(ass); //托管资产名称============================>>托管资产要不要查重?TODO
|
|
|
+ Integer attachmentId = attachmentService.generateAtachmentId(); //生成一个不重复的附件Id号==================>>生成id号的机制待定TODO
|
|
|
+
|
|
|
+ String path = request.getServletContext().getRealPath(""); //上传文件顶级父类的绝对路径============================>>路径机制待定TODO
|
|
|
+ //String relativePath = RelativePathUtil.formatPath("/"+userId,""); //生成默认的相对路径格式================================>>路径机制待定TODO
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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层中进行校验
|
|
|
|
|
|
+ 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进行前段提示
|
|
|
+ //文件最后上传到服务器
|
|
|
+ file.transferTo(newFile); //此时文件已经上传成功---->upload file success
|
|
|
+
|
|
|
+ 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进行前段提示
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -156,46 +309,198 @@ 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> uploadValuationPOIByBankOrByAdmin(@RequestParam("file") MultipartFile file,HttpServletRequest request,
|
|
|
+ @RequestParam("fundId") String fId,
|
|
|
+ @RequestParam("fundName") String fName,
|
|
|
+ @RequestParam("userId") Object uId) {
|
|
|
try {
|
|
|
- String path = request.getServletContext().getRealPath("")+SP+"content"; //SP是系统分隔符
|
|
|
+ if(file.isEmpty()){
|
|
|
+ throw new RuntimeException("上传文件不能为空");
|
|
|
+ }
|
|
|
+ //确定好上传的文件的顶级父级路径=======================================================================>>待定TODO
|
|
|
+ String path = request.getServletContext().getRealPath("")+SP+"content"; //SP是系统分隔符
|
|
|
File dir=new File(path);
|
|
|
if(!dir.exists()){
|
|
|
dir.mkdirs();
|
|
|
}
|
|
|
String filename = file.getOriginalFilename();
|
|
|
- String pathFile=path+SP+filename;
|
|
|
- File newFile=new File(pathFile);
|
|
|
- file.transferTo(newFile); //这里已经完成银行估值文件的上传,后续需要对该文件和管理岗上传文件中的报价信息进行比对,在Service层中进行校验
|
|
|
+ if(!(filename.endsWith(".xls")||filename.endsWith("xlsx"))){
|
|
|
+ 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
|
|
|
+ //先获取自己之前上传的文件路径
|
|
|
+ String custodianOldFilePath = path+valuationAccount.getUrl_of_custodian();
|
|
|
+ //核查文件是否还在
|
|
|
+ File oldFile = new File(custodianOldFilePath);
|
|
|
+ if(!oldFile.exists()){
|
|
|
+ throw new RuntimeException("之前上传的文件丢失");
|
|
|
+ }
|
|
|
+ //切断旧路径,拼接成新路径
|
|
|
+ String custodianNewFilePath = custodianOldFilePath.substring(0, custodianOldFilePath.lastIndexOf("/")+1)+filename;
|
|
|
+ File newFile=new File(custodianNewFilePath);
|
|
|
+
|
|
|
+ //再获取银行之前上传的文件路径
|
|
|
+ String bankFilePath = path+valuationAccount.getUrl_of_bank();
|
|
|
+ /*
|
|
|
+ * 如过不是excel文件类型,导入也会报错,然后就把这个新上传的文件删了
|
|
|
+ * 这里对两份文件进行估值报价的比对得出比对的结果是一致还是不一致
|
|
|
+ */
|
|
|
+ //获取比对结果
|
|
|
+ String result = "????";
|
|
|
+ Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
|
|
|
+ mapToService.put("userDetail", userDetail); //将用户的全部信息传入service层
|
|
|
+ mapToService.put("fundId", fundId);
|
|
|
+ mapToService.put("url", custodianNewFilePath); //将文件下载路径url通过map传到service层进行校验
|
|
|
+ mapToService.put("attachmentName", filename); //将文件以附件名的形式通过map传递到service层中进行校验
|
|
|
+ mapToService.put("battleResult", result); //将文件比对结果封装进去
|
|
|
+ mapToService.put("attachmentId", valuationAccount.getAttachment_id_of_custodian()); //获取之前上传的附件id号在附件表中修改
|
|
|
+ valuationAccountingService.updateInformationByAdmin(mapToService);
|
|
|
+
|
|
|
+ //文件的覆盖放到最后操作(重要!!!)
|
|
|
+ oldFile.delete();
|
|
|
+ file.transferTo(newFile);
|
|
|
+
|
|
|
+ return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个成功提示
|
|
|
+ }
|
|
|
|
|
|
- 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层中进行校验
|
|
|
+ //如果不是管理岗,那接下来的业务肯定是银行
|
|
|
+ //银行待对账操作
|
|
|
+ if(BattleResult.TO_BE_MATCHED.equals(battleResult)){
|
|
|
+ //待审核的状态说明文件是一个新的文件上传上去
|
|
|
+
|
|
|
+ //先获取管理员之前上传的文件
|
|
|
+ String custodianOldFilePath = path+SP+valuationAccount.getUrl_of_custodian();
|
|
|
+ //核查文件是否还在
|
|
|
+ File oldFile = new File(custodianOldFilePath);
|
|
|
+ if(!oldFile.exists()){
|
|
|
+ throw new RuntimeException("管理员上传的文件丢失");
|
|
|
+ }
|
|
|
+ //银行上传文件的新路径
|
|
|
+ String bankNewFilePath = path + SP + filename; //=========================>>新上传的文件路径怎么确定到时候再说TODO
|
|
|
+ File newFile=new File(bankNewFilePath);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 如过不是excel文件类型,导入也会报错,然后就把这个新上传的文件删了
|
|
|
+ * 这里对两份文件进行估值报价的比对得出比对的结果是一致还是不一致
|
|
|
+ */
|
|
|
+ //获取比对结果
|
|
|
+ String result = "????";
|
|
|
+
|
|
|
+ Integer attachmentId = attachmentService.generateAtachmentId(); //生成一个不重复的附件Id号==================>>生成id号的机制待定TODO
|
|
|
+
|
|
|
+ Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
|
|
|
+ mapToService.put("userDetail", userDetail); //将用户的全部信息传入service层
|
|
|
+ mapToService.put("fundId", fundId);
|
|
|
+ mapToService.put("url", "/content/"+filename); //将文件下载路径url通过map传到service层进行校验//=================>>新上传的文件路径怎么确定到时候再说TODO
|
|
|
+ mapToService.put("attachmentName", filename); //将文件以附件名的形式通过map传递到service层中进行校验
|
|
|
+ mapToService.put("battleResult", result); //将文件比对结果封装进去
|
|
|
+ mapToService.put("attachmentId", attachmentId);
|
|
|
+ valuationAccountingService.updateInformationByBank(mapToService);
|
|
|
+
|
|
|
+ //文件放到最后上传上去(重点!!!!)
|
|
|
+ file.transferTo(newFile);
|
|
|
+
|
|
|
+ return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个成功提示
|
|
|
+ }
|
|
|
|
|
|
- //这里是以银行的身份将数据进行更新
|
|
|
- valuationAccountingService.updateInformationByBank(map); //将获取到的数据更新到已有的估值核算表中,这个表是由管理岗创建的
|
|
|
+ //银行对账不一致操作
|
|
|
+ if(BattleResult.INCONSISTENT.equals(battleResult)){
|
|
|
+ //审核结果不一致的状态说明之前银行那边上传过一个文件,这次就要对之前的文件进行替换
|
|
|
+
|
|
|
+ //先获取管理员之前上传的文件
|
|
|
+ String custodianOldFilePath = path+valuationAccount.getUrl_of_custodian();
|
|
|
+ //核查文件是否还在
|
|
|
+ File oldCustodianFile = new File(custodianOldFilePath);
|
|
|
+ if(!oldCustodianFile.exists()){
|
|
|
+ throw new RuntimeException("管理员之前上传的文件丢失");
|
|
|
+ }
|
|
|
+ //银行之前上传文件的路径
|
|
|
+ String banckOldFilePath = path + valuationAccount.getUrl_of_bank();
|
|
|
+ //核查文件是否还在
|
|
|
+ File oldBankFile = new File(banckOldFilePath);
|
|
|
+ if(!oldBankFile.exists()){
|
|
|
+ throw new RuntimeException("银行之前上传的文件丢失");
|
|
|
+ }
|
|
|
+
|
|
|
+ //切断旧路径,拼接成新路径
|
|
|
+ String bankNewFilePath = banckOldFilePath.substring(0, banckOldFilePath.lastIndexOf("/")+1)+filename;
|
|
|
+ File newBankFile=new File(bankNewFilePath);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 如过不是excel文件类型,导入也会报错,然后就把这个新上传的文件删了(这里旧文件不能先删了)
|
|
|
+ * 这里对两份文件进行估值报价的比对得出比对的结果是一致还是不一致
|
|
|
+ */
|
|
|
+ //获取比对结果
|
|
|
+ String result = "????";
|
|
|
+
|
|
|
+ Map<String, Object> mapToService =new LinkedHashMap<String, Object>();
|
|
|
+ mapToService.put("userDetail", userDetail); //将用户的全部信息传入service层
|
|
|
+ mapToService.put("fundId", fundId);
|
|
|
+ mapToService.put("url", "/content/"+filename); //将文件下载路径url通过map传到service层进行校验//=================>>新上传的文件路径怎么确定到时候再说TODO
|
|
|
+ mapToService.put("attachmentName", filename); //将文件以附件名的形式通过map传递到service层中进行校验
|
|
|
+ mapToService.put("battleResult", result); //将文件比对结果封装进去
|
|
|
+ mapToService.put("attachmentId", valuationAccount.getAttachment_id_of_bank()); //获取之前银行上传的附件id号
|
|
|
+ valuationAccountingService.updateInformationByBank(mapToService);
|
|
|
+
|
|
|
+ //文件覆盖的这个操作放到最后操做(很重要!!!)
|
|
|
+ oldBankFile.delete();
|
|
|
+ file.transferTo(newBankFile);
|
|
|
+
|
|
|
+ return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS,null); //返回给前端一个成功提示
|
|
|
+ }
|
|
|
|
|
|
- return JSONUtil.getJsonMap(200, true, "上传成功",null); //返回给前端一个map进行前段提示
|
|
|
+ //能运行到这里肯定有问题
|
|
|
+ throw new RuntimeException("你是怎么运行到这里的");
|
|
|
} catch (Exception e) {
|
|
|
- return JSONUtil.getJsonMap(500, false, "上传出现异常"+e.getMessage(),null); //返回给前端一个map进行前段提示
|
|
|
+ return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(),null); //返回给前端一个map进行前段提示
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/test",method=RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> test(@RequestBody String data){
|
|
|
+ try {
|
|
|
+ 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); //查看用户非空和权限(管理员创建并上传的权限)
|
|
|
+ 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进行前段提示
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
|
|
|
}
|