|
@@ -1,7 +1,9 @@
|
|
|
package com.sy.coinage.workshop.controller;
|
|
|
|
|
|
+import com.sy.coinage.config.CustomConfig;
|
|
|
import com.sy.coinage.core.redis.RedisService;
|
|
|
import com.sy.coinage.core.util.DateUtils;
|
|
|
+import com.sy.coinage.file.model.MyFile;
|
|
|
import com.sy.coinage.sys.model.Dict;
|
|
|
import com.sy.coinage.sys.service.IDictService;
|
|
|
import com.sy.coinage.workshop.service.IProductService;
|
|
@@ -15,10 +17,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import com.sy.coinage.core.annotation.ActiveFastJsonProfile;
|
|
|
import com.sy.coinage.core.annotation.CurrentUser;
|
|
@@ -39,6 +38,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* -发货单主表Controller
|
|
@@ -60,6 +63,9 @@ public class DeliveryController extends BaseController {
|
|
|
@Autowired
|
|
|
private IDictService dictService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CustomConfig customConfig;
|
|
|
+
|
|
|
/**
|
|
|
* 发货单主表分页列表
|
|
|
*/
|
|
@@ -210,4 +216,49 @@ public class DeliveryController extends BaseController {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/imp")
|
|
|
+ public Object imp(@RequestParam(required = true) MultipartFile file,
|
|
|
+ @RequestParam(required = true) Integer id, @RequestParam(required = true) Integer type,
|
|
|
+ @CurrentUser CacheUserVO user) throws Exception {
|
|
|
+ String saveUrl = this.imp(file);
|
|
|
+ Delivery model = this.deliveryService.getById(id);
|
|
|
+ String filePath = customConfig.getAttaPath() + model.getTransportUrl();
|
|
|
+ File f = new File(filePath);
|
|
|
+ if (f.exists()) {
|
|
|
+ f.delete();
|
|
|
+ }
|
|
|
+ if (type != null && type == 1) {
|
|
|
+ model.setTransportUrl(saveUrl);
|
|
|
+ } else {
|
|
|
+ model.setBranchUrl(saveUrl);
|
|
|
+ }
|
|
|
+ this.deliveryService.updateById(model);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private String imp(MultipartFile file) throws Exception {
|
|
|
+ String date = DateUtils.toString(new Date(), DateUtils.YYMMDD);
|
|
|
+ // 上传文件的名称
|
|
|
+ String fname = file.getOriginalFilename();
|
|
|
+ // 获取后缀
|
|
|
+ String sufferFix = fname.substring(fname.lastIndexOf("."));
|
|
|
+ // 访问url
|
|
|
+ String fileUrl = customConfig.getPathUrl() + "/" + date;
|
|
|
+ // 存储路径
|
|
|
+ String filePath = customConfig.getAttaPath() + fileUrl;
|
|
|
+ File path = new File(filePath);
|
|
|
+ if (!path.exists()) {
|
|
|
+ path.mkdirs();
|
|
|
+ }
|
|
|
+ long s = System.currentTimeMillis();
|
|
|
+ // 文件访问url
|
|
|
+ String saveUrl = fileUrl + "/" + s + sufferFix;
|
|
|
+ // 文件存储路径
|
|
|
+ String savePath = filePath + "/" + s + sufferFix;
|
|
|
+ File dest = new File(savePath);
|
|
|
+ // 生成临时文件
|
|
|
+ file.transferTo(dest.getAbsoluteFile());
|
|
|
+ return saveUrl;
|
|
|
+ }
|
|
|
+
|
|
|
}
|