|
@@ -1,17 +1,25 @@
|
|
|
package top.lvzhiqiang.controller;
|
|
package top.lvzhiqiang.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+import top.lvzhiqiang.config.WebAppConfig;
|
|
|
import top.lvzhiqiang.dto.R;
|
|
import top.lvzhiqiang.dto.R;
|
|
|
import top.lvzhiqiang.exception.ParameterException;
|
|
import top.lvzhiqiang.exception.ParameterException;
|
|
|
import top.lvzhiqiang.service.BgService;
|
|
import top.lvzhiqiang.service.BgService;
|
|
|
import top.lvzhiqiang.util.StringUtils;
|
|
import top.lvzhiqiang.util.StringUtils;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* BG Controller
|
|
* BG Controller
|
|
@@ -26,6 +34,9 @@ public class BgController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private BgService bgService;
|
|
private BgService bgService;
|
|
|
|
|
|
|
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
|
|
+ private String env;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 初始化骑兵数据
|
|
* 初始化骑兵数据
|
|
@@ -302,4 +313,45 @@ public class BgController {
|
|
|
bgService.insertVideoInfo(identificationCode.trim().toUpperCase(), videoName, parentType, parentName, type);
|
|
bgService.insertVideoInfo(identificationCode.trim().toUpperCase(), videoName, parentType, parentName, type);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上传影片识别码
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lvzhiqiang
|
|
|
|
|
+ * 2022/9/30 19:46
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping("/uploadVideoInfoImgs")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public R uploadVideoInfoImgs(@RequestParam("files") MultipartFile[] files, String identificationCode, String imgType) throws Exception {
|
|
|
|
|
+ if (StringUtils.isEmpty(identificationCode)) {
|
|
|
|
|
+ throw new ParameterException("识别码不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (files == null || files.length == 0) {
|
|
|
|
|
+ throw new ParameterException("文件为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String qibingPath = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && env.equals(x.getEnv()) && "apics_path".equals(x.getCodeKey())).findFirst().get().getCodeValue();
|
|
|
|
|
+ File imgParentFile = new File(qibingPath.concat("骑兵步兵/").concat(identificationCode.trim().toUpperCase()).concat("/").concat(imgType));
|
|
|
|
|
+ if (!imgParentFile.exists()) {
|
|
|
|
|
+ imgParentFile.mkdirs();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
|
|
+ int i = 0;
|
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
|
+ for (MultipartFile file : files) {
|
|
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
|
|
+
|
|
|
|
|
+ File imgFile = new File(imgParentFile, originalFilename);
|
|
|
|
|
+ file.transferTo(imgFile);
|
|
|
|
|
+
|
|
|
|
|
+ i++;
|
|
|
|
|
+ jsonArray.add(BigDecimal.valueOf(file.getSize()).divide(new BigDecimal("1024")).setScale(0, RoundingMode.UP).toPlainString().concat("KB"));
|
|
|
|
|
+ }
|
|
|
|
|
+ result.put("totalNum", i);
|
|
|
|
|
+ result.put("list", jsonArray);
|
|
|
|
|
+
|
|
|
|
|
+ return R.ok().data(result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|