|
@@ -15,19 +15,18 @@ import com.jeeplus.test.garbageClearance.domain.LookOver;
|
|
|
import com.jeeplus.test.garbageClearance.service.DTO.LookOverDTO;
|
|
|
import com.jeeplus.test.garbageClearance.service.LookOverService;
|
|
|
import com.jeeplus.test.garbageClearance.utils.SnowFlake;
|
|
|
+import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
import com.jeeplus.test.oss.domain.WorkAttachmentInfo;
|
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 巡视相关controller
|
|
@@ -95,6 +94,7 @@ public class LookOverController {
|
|
|
attachment.setCreateTime(new Date());
|
|
|
attachment.setUpdateTime(new Date());
|
|
|
attachment.setDelFlag(0);
|
|
|
+ attachment.setAttachmentFlag("before");
|
|
|
ossService.insertWorkAttachmentInfo(attachment,userDTO);
|
|
|
}
|
|
|
}
|
|
@@ -112,12 +112,94 @@ public class LookOverController {
|
|
|
|
|
|
notifyService.saveOrUpdate ( notifyDTO );
|
|
|
|
|
|
-
|
|
|
+ lookOver.setStatus("1");
|
|
|
overService.saveOrUpdate (lookOver);
|
|
|
return ResponseEntity.ok ( "保存成功" );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 保存巡视信息
|
|
|
+ */
|
|
|
+ @ApiLog("保存巡视信息处理中后的图片信息")
|
|
|
+ @ApiOperation(value = "保存巡视信息处理中后的图片信息")
|
|
|
+ @PostMapping("savePhoto")
|
|
|
+ public ResponseEntity <String> savePhoto(@Valid @RequestBody LookOver lookOver) {
|
|
|
+ //新增或编辑表单保存
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ List<String> betweenUrlList = Lists.newArrayList();
|
|
|
+ if (null != lookOver.getFileList2() && lookOver.getFileList2().size() > 0 ) {
|
|
|
+ // 进行附件保存操作,保存到work_attachment 表中
|
|
|
+ for (WorkAttachmentInfo attachment : lookOver.getFileList2()) {
|
|
|
+ if(attachment.getUrl().contains("/attachment-file")){
|
|
|
+ // 查找 "/attachment-file" 在字符串中的位置
|
|
|
+ int startIndex = attachment.getUrl().indexOf("/attachment-file");
|
|
|
+ // 查找 "?" 在字符串中的位置
|
|
|
+ int endIndex = attachment.getUrl().indexOf("?");
|
|
|
+ // 如果找到了 "/attachment-file" 和 "?"
|
|
|
+ if (startIndex != -1 && endIndex != -1) {
|
|
|
+ // 截取从 startIndex 到 endIndex 之间的字符串
|
|
|
+ String result = attachment.getUrl().substring(startIndex+1, endIndex);
|
|
|
+ betweenUrlList.add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询除betweenUrlList以外的数据进行删除
|
|
|
+ ossService.deleteByUrlListAndFlag(betweenUrlList,"between", lookOver.getId());
|
|
|
+ for (WorkAttachmentInfo attachment : lookOver.getFileList2()) {
|
|
|
+ if(StringUtils.isNotBlank(attachment.getAttachmentName())){
|
|
|
+ // 生成id
|
|
|
+ String detailId = SnowFlake.getId();
|
|
|
+ attachment.setId(detailId);
|
|
|
+ attachment.setAttachmentId(lookOver.getId());
|
|
|
+ attachment.setCreateTime(new Date());
|
|
|
+ attachment.setUpdateTime(new Date());
|
|
|
+ attachment.setDelFlag(0);
|
|
|
+ attachment.setAttachmentFlag("between");
|
|
|
+ ossService.insertWorkAttachmentInfo(attachment,userDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (null != lookOver.getFileList3() && lookOver.getFileList3().size() > 0 ) {
|
|
|
+ List<String> afterUrlList = Lists.newArrayList();
|
|
|
+ // 进行附件保存操作,保存到work_attachment 表中
|
|
|
+ for (WorkAttachmentInfo attachment : lookOver.getFileList3()) {
|
|
|
+ if (attachment.getUrl().contains("/attachment-file")) {
|
|
|
+ // 查找 "/attachment-file" 在字符串中的位置
|
|
|
+ int startIndex = attachment.getUrl().indexOf("/attachment-file");
|
|
|
+ // 查找 "?" 在字符串中的位置
|
|
|
+ int endIndex = attachment.getUrl().indexOf("?");
|
|
|
+ // 如果找到了 "/attachment-file" 和 "?"
|
|
|
+ if (startIndex != -1 && endIndex != -1) {
|
|
|
+ // 截取从 startIndex 到 endIndex 之间的字符串
|
|
|
+ String result = attachment.getUrl().substring(startIndex + 1, endIndex);
|
|
|
+ afterUrlList.add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询除afterUrlList以外的数据进行删除
|
|
|
+ ossService.deleteByUrlListAndFlag(afterUrlList, "after", lookOver.getId());
|
|
|
+
|
|
|
+ // 进行附件保存操作,保存到work_attachment 表中
|
|
|
+ for (WorkAttachmentInfo attachment : lookOver.getFileList3()) {
|
|
|
+ if(StringUtils.isNotBlank(attachment.getAttachmentName())) {
|
|
|
+ // 生成id
|
|
|
+ String detailId = SnowFlake.getId();
|
|
|
+ attachment.setId(detailId);
|
|
|
+ attachment.setAttachmentId(lookOver.getId());
|
|
|
+ attachment.setCreateTime(new Date());
|
|
|
+ attachment.setUpdateTime(new Date());
|
|
|
+ attachment.setDelFlag(0);
|
|
|
+ attachment.setAttachmentFlag("after");
|
|
|
+ ossService.insertWorkAttachmentInfo(attachment, userDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok ( "保存成功" );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询最大的巡视工单
|
|
|
*/
|
|
|
@ApiLog("查询最大的巡视工单")
|
|
@@ -176,4 +258,23 @@ public class LookOverController {
|
|
|
return ResponseEntity.ok (result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据关联id和判定条件查询附件信息
|
|
|
+ * @param attachmentId
|
|
|
+ * @param attachmentFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiLog("根据关联id和判定条件查询附件信息")
|
|
|
+ @GetMapping("getPhotoListByAttachmentAndFlag")
|
|
|
+ public List<WorkAttachment> getPhotoListByAttachmentAndFlag(String attachmentId,String attachmentFlag){
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
+ String[] attachmentIds = attachmentId.split(",");
|
|
|
+ for (String id : attachmentIds) {
|
|
|
+ set.add(id);
|
|
|
+ }
|
|
|
+ List<String> attachmentIdList = new ArrayList<>(set);
|
|
|
+ List<WorkAttachment> fileList = ossService.findFileList(attachmentIdList, attachmentFlag);
|
|
|
+ return fileList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|