|
@@ -0,0 +1,164 @@
|
|
|
+package com.kmall.admin.controller;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import com.kmall.admin.entity.SalesDataDownloadEntity;
|
|
|
+import com.kmall.admin.entity.SalesDataUploadEntity;
|
|
|
+import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
+import com.kmall.admin.service.SalesDataUploadService;
|
|
|
+import com.kmall.admin.utils.ShiroUtils;
|
|
|
+import com.kmall.common.fileserver.util.FileManager;
|
|
|
+import com.kmall.common.utils.*;
|
|
|
+import com.kmall.common.utils.excel.FileUtil;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.apache.tools.ant.util.FileUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 销售数据上传表Controller
|
|
|
+ *
|
|
|
+ * @author emato
|
|
|
+ * @email admin@qhdswl.com
|
|
|
+ * @date 2020-11-16 14:11:53
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping("salesdataupload")
|
|
|
+public class SalesDataUploadController {
|
|
|
+ @Autowired
|
|
|
+ private SalesDataUploadService salesDataUploadService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看列表
|
|
|
+ */
|
|
|
+ @RequestMapping("/list")
|
|
|
+// @RequiresPermissions("salesdataupload:list")
|
|
|
+ @ResponseBody
|
|
|
+ public R list(@RequestParam Map<String, Object> params) {
|
|
|
+ //查询列表数据
|
|
|
+ Query query = new Query(params);
|
|
|
+
|
|
|
+ List<SalesDataUploadEntity> salesDataUploadList = salesDataUploadService.queryList(query);
|
|
|
+ int total = salesDataUploadService.queryTotal(query);
|
|
|
+
|
|
|
+ PageUtils pageUtil = new PageUtils(salesDataUploadList, total, query.getLimit(), query.getPage());
|
|
|
+
|
|
|
+ return R.ok().put("page", pageUtil);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看信息
|
|
|
+ */
|
|
|
+ @RequestMapping("/info/{fileId}")
|
|
|
+ @RequiresPermissions("salesdataupload:info")
|
|
|
+ @ResponseBody
|
|
|
+ public R info(@PathVariable("fileId") Integer fileId) {
|
|
|
+ SalesDataUploadEntity salesDataUpload = salesDataUploadService.queryObject(fileId);
|
|
|
+
|
|
|
+ return R.ok().put("salesDataUpload", salesDataUpload);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ */
|
|
|
+ @RequestMapping("/save")
|
|
|
+// @RequiresPermissions("salesdataupload:save")
|
|
|
+ @ResponseBody
|
|
|
+ public R save(@RequestBody SalesDataUploadEntity salesDataUpload) {
|
|
|
+ salesDataUploadService.save(salesDataUpload);
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @RequestMapping("/update")
|
|
|
+ @RequiresPermissions("salesdataupload:update")
|
|
|
+ @ResponseBody
|
|
|
+ public R update(@RequestBody SalesDataUploadEntity salesDataUpload) {
|
|
|
+ salesDataUploadService.update(salesDataUpload);
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @RequestMapping("/delete")
|
|
|
+// @RequiresPermissions("salesdataupload:delete")
|
|
|
+ @ResponseBody
|
|
|
+ public R delete(@RequestBody Integer[]fileIds) {
|
|
|
+ salesDataUploadService.deleteBatch(fileIds);
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看所有列表
|
|
|
+ */
|
|
|
+ @RequestMapping("/queryAll")
|
|
|
+ @ResponseBody
|
|
|
+ public R queryAll(@RequestParam Map<String, Object> params) {
|
|
|
+
|
|
|
+ List<SalesDataUploadEntity> list = salesDataUploadService.queryList(params);
|
|
|
+
|
|
|
+ return R.ok().put("list", list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传文件
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping("/upload")
|
|
|
+ @ResponseBody
|
|
|
+ public R upload(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ throw new RRException("上传文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传文件
|
|
|
+ String url = FileManager.upload(file);
|
|
|
+
|
|
|
+ SalesDataUploadEntity salesDataUploadEntity = new SalesDataUploadEntity();
|
|
|
+ salesDataUploadEntity.setFileName(file.getOriginalFilename());
|
|
|
+ salesDataUploadEntity.setFileType(file.getContentType());
|
|
|
+ salesDataUploadEntity.setUploadAddress(url);
|
|
|
+ salesDataUploadEntity.setCreaterSn(ShiroUtils.getUserId().intValue());
|
|
|
+ salesDataUploadEntity.setCreaterTime(new Date());
|
|
|
+ salesDataUploadService.save(salesDataUploadEntity);
|
|
|
+
|
|
|
+ R r = R.ok();
|
|
|
+ r.put("url", url);
|
|
|
+ r.put("salesDataUpload", salesDataUploadEntity);
|
|
|
+ return r;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件下载
|
|
|
+ * @param filePath
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping("/download")
|
|
|
+ public ResponseEntity<byte[]> download(@RequestParam("filePath") String filePath, @RequestParam("fileName") String fileName, @RequestParam("fileId") String fileId) throws Exception {
|
|
|
+ if(StringUtils.isNotEmpty(filePath)){
|
|
|
+ SalesDataDownloadEntity salesDataDownloadEntity = new SalesDataDownloadEntity();
|
|
|
+ salesDataDownloadEntity.setFileId(Integer.valueOf(fileId));
|
|
|
+ salesDataDownloadEntity.setDownloadSn(ShiroUtils.getUserId().intValue());
|
|
|
+ salesDataDownloadEntity.setDownloadTime(new Date());
|
|
|
+ salesDataUploadService.saveSalesDownload(salesDataDownloadEntity);
|
|
|
+
|
|
|
+ return FileManager.download(filePath, fileName);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|