|
@@ -1,23 +1,32 @@
|
|
|
package com.fuzamei.web;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+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.HintMSG;
|
|
|
import com.fuzamei.constant.Role;
|
|
|
+import com.fuzamei.constant.StatusId;
|
|
|
+import com.fuzamei.entity.ContractStatusTracking;
|
|
|
import com.fuzamei.entity.UserDetail;
|
|
|
+import com.fuzamei.service.AttachmentService;
|
|
|
import com.fuzamei.service.ContractManagementService;
|
|
|
import com.fuzamei.service.UserAuthoricationService;
|
|
|
import com.fuzamei.utils.JSONUtil;
|
|
|
import com.fuzamei.utils.PageDTO;
|
|
|
+import com.fuzamei.utils.RelativePathUtil;
|
|
|
import com.fuzamei.utils.ValidationUtil;
|
|
|
|
|
|
/**
|
|
@@ -35,6 +44,9 @@ public class ContractManagementAction {
|
|
|
@Autowired
|
|
|
private UserAuthoricationService userAuthoricationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AttachmentService attachmentService;
|
|
|
+
|
|
|
private static final int ROW_NUM = 10; // 分页每页显示数据的数量
|
|
|
/**
|
|
|
*
|
|
@@ -109,7 +121,7 @@ public class ContractManagementAction {
|
|
|
*/
|
|
|
@RequestMapping(value="/queryContractRecordByBusinessId",method=RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public Map<String, Object> queryContractRecordByBusinessId(@RequestBody String data){
|
|
|
+ private Map<String, Object> queryContractRecordByBusinessId(@RequestBody String data){
|
|
|
try {
|
|
|
System.out.println("查询合同状态跟踪表....");
|
|
|
@SuppressWarnings("unchecked")
|
|
@@ -131,5 +143,69 @@ public class ContractManagementAction {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传新版本合同操作
|
|
|
+ * @Title: uploadNewVersionContract
|
|
|
+ * @Description: TODO(这里用一句话描述这个方法的作用)
|
|
|
+ * @param @return 设定文件
|
|
|
+ * @return Map<String,Object> 返回类型
|
|
|
+ * @author ylx
|
|
|
+ * @date 2018年1月8日 下午7:40:51
|
|
|
+ * @throws
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/uploadNewVersionContract")
|
|
|
+ @ResponseBody
|
|
|
+ private Map<String, Object> uploadNewVersionContract(@RequestParam("file") MultipartFile file,
|
|
|
+ @RequestParam("userId") Object uId,
|
|
|
+ @RequestParam("modifyOpinion") String mOpinion,
|
|
|
+ @RequestParam("businessId") Object bId,
|
|
|
+ HttpServletRequest request){
|
|
|
+ try {
|
|
|
+ System.out.println("上传新版本合同操作....");
|
|
|
+ if(file.isEmpty()) throw new RuntimeException("文件不能为空");
|
|
|
+ String filename = file.getOriginalFilename();
|
|
|
+ if(!filename.endsWith(".pdf")||!filename.endsWith(".doc")||!filename.endsWith(".docx")) throw new RuntimeException("文件上传格式不正确");
|
|
|
+ int userId = ValidationUtil.checkAndAssignInt(uId);
|
|
|
+ //只有管理员,省分行业务主管部门,省分行法律部才有权限可以查看
|
|
|
+ UserDetail userDetail = userAuthoricationService.checkUserAuthority(userId, Role.ADMIN,Role.BUSINESS_CHIEF_DEP_OF_PBB,Role.LAW_DEP_OF_PBB);
|
|
|
+ //这里的businessId是必查条件,所以不能默认为null,应该强制转换成int类型
|
|
|
+ Integer businessId = ValidationUtil.checkAndAssignInt(bId);
|
|
|
+ String modifyOpinion = ValidationUtil.checkBlankAndAssignString(mOpinion);
|
|
|
+ ContractStatusTracking contractStatusTracking = contractManagementService.getContractStatusTrackingByBusinessId(businessId);
|
|
|
+ if(contractStatusTracking==null) throw new RuntimeException("无该合同信息");
|
|
|
+ //如果已经确认过报错
|
|
|
+ if(contractStatusTracking.getStatus_id()==StatusId.CONFIRMED) throw new RuntimeException("合同已确认");//已确认id是8
|
|
|
+
|
|
|
+ //确定好上传的文件的顶级父级路径=======================================================================>>待定TODO
|
|
|
+ String path = request.getServletContext().getRealPath(""); //SP是系统分隔符
|
|
|
+ String relativePath = RelativePathUtil.formatPath("/"+userId, ""); //生成文件的相对保存路径
|
|
|
+
|
|
|
+ int contractId = attachmentService.generateAtachmentId();//生成不重复的附件id号
|
|
|
+
|
|
|
+ Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
|
|
|
+ mapToService.put("contractId", contractId);
|
|
|
+ mapToService.put("contractName", filename);
|
|
|
+ mapToService.put("modifyOpinion", modifyOpinion);
|
|
|
+ mapToService.put("userDetail", userDetail);
|
|
|
+ mapToService.put("hash", "to be calculated"); //文件hash待定
|
|
|
+ contractManagementService.uploadContractByUser(mapToService);
|
|
|
+
|
|
|
+ String pathFile=path+relativePath+filename;
|
|
|
+ File newFile = new File(pathFile);
|
|
|
+ //==========文件上传开始============
|
|
|
+ File dir=new File(path+relativePath);
|
|
|
+ if(!dir.exists()){
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+ file.transferTo(newFile); //将---合同---文件上传到指定的文件夹下
|
|
|
+ //==========文件上传结束============
|
|
|
+
|
|
|
+ return JSONUtil.getJsonMap(200, true, HintMSG.UPLOAD_SUCCESS, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JSONUtil.getJsonMap(500, false, HintMSG.UPLOAD_FAIL+":"+e.getMessage(), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|