|
@@ -49,22 +49,24 @@ public class FileUploadController {
|
|
|
@Value("${config.fileupload.warpath}")
|
|
|
private String warPath;
|
|
|
|
|
|
-//上传用户模型及审批结果
|
|
|
+ //上传用户模型及审批结果
|
|
|
@PostMapping("/fileupload")
|
|
|
@ResponseBody
|
|
|
public Result upload2(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
|
|
|
- , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String output_list, SysUser sysUser
|
|
|
- ) throws IOException {
|
|
|
+ , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String output_list, SysUser sysUser
|
|
|
+ ) throws IOException {
|
|
|
int type=Integer.parseInt(model_type);
|
|
|
- if(type==1 || type==2)
|
|
|
+ if(type==1 || type==2)
|
|
|
{
|
|
|
String filename = name.split("\\.")[0];
|
|
|
String filefmt = name.split("\\.")[1];
|
|
|
String fullFileName = String.join("-", new String[] {filename, uid, index + "", "." + filefmt});
|
|
|
log.info("filename:" + fullFileName);
|
|
|
File dir = new File(fileuploadPath+ "/" +sysUser.getUserName()+"/");
|
|
|
+
|
|
|
if (!dir.exists())
|
|
|
dir.mkdirs();
|
|
|
+
|
|
|
File file = new File(fileuploadPath + "/" +sysUser.getUserName()+"/"+ fullFileName);
|
|
|
FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
|
|
|
FileUploadUtil.put(uid, index, chunksLength, fullFileName, fileuploadPath+ "/" +sysUser.getUserName()+"/");
|
|
@@ -81,76 +83,78 @@ public class FileUploadController {
|
|
|
}
|
|
|
|
|
|
//审批
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
- approval.setUserName(sysUser.getUserName());
|
|
|
- approval.setApprovalId((long) 1);
|
|
|
- approval.setData(model_name);
|
|
|
- userApprovalService.save(approval);
|
|
|
+// UserApproval approval=new UserApproval();
|
|
|
+// approval.setUserName(sysUser.getUserName());
|
|
|
+// approval.setApprovalId((long) 1);
|
|
|
+// approval.setData(model_name);
|
|
|
+// userApprovalService.save(approval);
|
|
|
|
|
|
|
|
|
//model 数据库连接接口
|
|
|
String userName=sysUser.getUserName();
|
|
|
UserModel new_model=new UserModel();
|
|
|
- new_model.setUserName(userName);
|
|
|
+ new_model.setCreateBy(userName);
|
|
|
new_model.setModelName(model_name);
|
|
|
new_model.setModelType(type);
|
|
|
- new_model.setModelState("审批中");
|
|
|
- new_model.setOtherData(name);
|
|
|
- new_model.setOutputList(output_list);
|
|
|
+ new_model.setStatus("暂停使用");
|
|
|
+// new_model.setOtherData(name);
|
|
|
+// new_model.setOutputList(output_list);
|
|
|
+ new_model.setFilePath(fileuploadPath + "/" +sysUser.getUserName()+"/"+ fullFileName);
|
|
|
userModelService.save(new_model);
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // http请求
|
|
|
- String filename = name.split("\\.")[0];
|
|
|
- String filefmt = name.split("\\.")[1];
|
|
|
- String fullFileName = String.join("-", new String[] {filename, uid, index + "", "." + filefmt});
|
|
|
- log.info("filename:" + fullFileName);
|
|
|
- File dir = new File(warPath);
|
|
|
- if (!dir.exists())
|
|
|
- dir.mkdirs();
|
|
|
- File file = new File(warPath + "/" + fullFileName);
|
|
|
- FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
|
|
|
- FileUploadUtil.put(uid, index, chunksLength, fullFileName, warPath);
|
|
|
- // 检测所有文件是否上传完成
|
|
|
- boolean isAllChunksUploaded = FileUploadUtil.isAllChunksUploaded(uid);
|
|
|
- //当前步骤这一步一定完成
|
|
|
- try {
|
|
|
- if (isAllChunksUploaded) {
|
|
|
- FileUploadUtil.mergeChunks(name, uid);
|
|
|
- }
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- throw new RuntimeException(ex.getMessage());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // http请求
|
|
|
+ String filename = name.split("\\.")[0];
|
|
|
+ String filefmt = name.split("\\.")[1];
|
|
|
+ String fullFileName = String.join("-", new String[] {filename, uid, index + "", "." + filefmt});
|
|
|
+ log.info("filename:" + fullFileName);
|
|
|
+ File dir = new File(warPath);
|
|
|
+ if (!dir.exists())
|
|
|
+ dir.mkdirs();
|
|
|
+ File file = new File(warPath + "/" + fullFileName);
|
|
|
+ FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
|
|
|
+ FileUploadUtil.put(uid, index, chunksLength, fullFileName, warPath);
|
|
|
+ // 检测所有文件是否上传完成
|
|
|
+ boolean isAllChunksUploaded = FileUploadUtil.isAllChunksUploaded(uid);
|
|
|
+ //当前步骤这一步一定完成
|
|
|
+ try {
|
|
|
+ if (isAllChunksUploaded) {
|
|
|
+ FileUploadUtil.mergeChunks(name, uid);
|
|
|
}
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ throw new RuntimeException(ex.getMessage());
|
|
|
+ }
|
|
|
|
|
|
- //审批
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
- approval.setUserName(sysUser.getUserName());
|
|
|
- approval.setApprovalId((long) 1);
|
|
|
+ //审批
|
|
|
+ UserApproval approval=new UserApproval();
|
|
|
+ approval.setUserName(sysUser.getUserName());
|
|
|
+ approval.setApprovalId((long) 1);
|
|
|
|
|
|
|
|
|
- approval.setData(model_name.split(";")[0]);
|
|
|
+ approval.setData(model_name.split(";")[0]);
|
|
|
|
|
|
- String url_address=model_name.split(";")[1];
|
|
|
+ String url_address=model_name.split(";")[1];
|
|
|
|
|
|
- userApprovalService.save(approval);
|
|
|
+ userApprovalService.save(approval);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- String userName=sysUser.getUserName();
|
|
|
- UserModel new_model=new UserModel();
|
|
|
- new_model.setUserName(userName);
|
|
|
- new_model.setModelName(model_name);
|
|
|
- new_model.setModelType(type);
|
|
|
- new_model.setModelState("审批中");
|
|
|
- new_model.setOtherData(name);
|
|
|
- new_model.setOutputList(output_list);
|
|
|
- userModelService.save(new_model);
|
|
|
- }
|
|
|
- return Result.success();
|
|
|
+ String userName=sysUser.getUserName();
|
|
|
+ UserModel new_model=new UserModel();
|
|
|
+ new_model.setCreateBy(userName);
|
|
|
+ new_model.setModelName(model_name);
|
|
|
+ new_model.setModelType(type);
|
|
|
+ new_model.setStatus("暂停使用");
|
|
|
+// new_model.setOtherData(name);
|
|
|
+// new_model.setOutputList(output_list);
|
|
|
+ new_model.setFilePath(warPath + "/" + fullFileName);
|
|
|
+ userModelService.save(new_model);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get")
|