|
@@ -1,10 +1,10 @@
|
|
|
package com.platform.rest.controller.mobile;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.constant.CommonConstants;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
-import com.platform.common.util.BeanConverterUtil;
|
|
|
-import com.platform.common.util.R;
|
|
|
-import com.platform.common.util.SecurityUtils;
|
|
|
+import com.platform.common.util.*;
|
|
|
import com.platform.common.validation.group.AddGroup;
|
|
|
import com.platform.common.validation.group.UpdateGroup;
|
|
|
import com.platform.dao.dto.check.CheckJobDTO;
|
|
@@ -16,6 +16,7 @@ import com.platform.dao.enums.CheckStandardTypeEnum;
|
|
|
import com.platform.dao.enums.RepairApplicationFormStatusEnum;
|
|
|
import com.platform.dao.util.ExcelUtil;
|
|
|
import com.platform.dao.util.TreeUtil;
|
|
|
+import com.platform.dao.vo.FileVO;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoMeasureVO;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
import com.platform.dao.vo.index.GatherTaskVO;
|
|
@@ -27,7 +28,12 @@ import com.platform.rest.log.annotation.SysLog;
|
|
|
import com.platform.service.check.CheckJobService;
|
|
|
import com.platform.service.repair.RepairApplicationFormService;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
+import com.platform.service.upms.SysFileService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -38,6 +44,7 @@ import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -47,13 +54,18 @@ import java.util.List;
|
|
|
* @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
*/
|
|
|
@RestController
|
|
|
-@AllArgsConstructor
|
|
|
@RequestMapping("/ignores")
|
|
|
public class IgnoreController {
|
|
|
-
|
|
|
- private final SbInfoService sbInfoService;
|
|
|
- private final RepairApplicationFormService repairApplicationFormService;
|
|
|
- private final CheckJobService checkJobService;
|
|
|
+ @Value("${upload.root-dir}")
|
|
|
+ private String UPLOAD_ROOT_FOLDER;
|
|
|
+ @Autowired
|
|
|
+ private SysFileService sysFileService;
|
|
|
+ @Autowired
|
|
|
+ private SbInfoService sbInfoService;
|
|
|
+ @Autowired
|
|
|
+ private RepairApplicationFormService repairApplicationFormService;
|
|
|
+ @Autowired
|
|
|
+ private CheckJobService checkJobService;
|
|
|
|
|
|
/**
|
|
|
* 通过id查询单条记录
|
|
@@ -65,7 +77,18 @@ public class IgnoreController {
|
|
|
public R<SbInfoVO> getById(@PathVariable("id") String id) {
|
|
|
return new R<>(sbInfoService.getById(id));
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 更新设备图片
|
|
|
+ *
|
|
|
+ * @param sbInfoDTO 设备基础信息DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("更新设备图片信息")
|
|
|
+ @PutMapping("/sb/images/{id}")
|
|
|
+ public R updateImages(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
+ sbInfoService.modImagesByDTO(sbInfoDTO);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
/**
|
|
|
* 新增记录
|
|
|
*
|
|
@@ -148,9 +171,44 @@ public class IgnoreController {
|
|
|
*/
|
|
|
@SysLog("完成点检任务")
|
|
|
@PutMapping("/check/jobs/finish")
|
|
|
- @PreAuthorize("@pms.hasPermission('check-polling-jobs-edit')")
|
|
|
public R finishJob(@Validated({UpdateGroup.class}) @RequestBody CheckJobDTO checkJobDTO) {
|
|
|
checkJobService.finishJob(checkJobDTO);
|
|
|
return new R<>();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件上传
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return :
|
|
|
+ */
|
|
|
+ @PostMapping("/files/upload")
|
|
|
+ @SneakyThrows
|
|
|
+ public R doUpload(@RequestParam("file") MultipartFile file) {
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return R.error("请选择一个上传文件");
|
|
|
+ }
|
|
|
+ FileVO fileVO = new FileVO();
|
|
|
+
|
|
|
+ String fileFullName = file.getOriginalFilename();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(fileFullName)) {
|
|
|
+ fileFullName = fileFullName.replace(",", ",");
|
|
|
+ fileVO.setName(fileFullName);
|
|
|
+ int endIndex = fileFullName.lastIndexOf(".");
|
|
|
+ fileVO.setFileName(fileFullName.substring(0, endIndex));
|
|
|
+ fileVO.setFileFormat(fileFullName.substring(endIndex + 1));
|
|
|
+ String fileType = fileFullName.substring(endIndex);
|
|
|
+ String path = CommonConstants.RESOURCE_PREFIX + "/" + fileVO.getFileFormat() + "/" + DateUtil.formatDate(new Date()) + "/" + IdGeneratorUtils.getObjectId() + "/";
|
|
|
+ String filePath = UPLOAD_ROOT_FOLDER + path;
|
|
|
+ fileVO.setUrl(path + fileFullName);
|
|
|
+ fileVO.setFileFormat(fileType);
|
|
|
+ try {
|
|
|
+ FileUtils.uploadFile(file.getBytes(), filePath, fileFullName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new Exception("上传文件失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success(fileVO, "上传成功");
|
|
|
+ }
|
|
|
}
|