|
@@ -1,22 +1,16 @@
|
|
|
package com.jeeplus.test.wdt.disposeRubbish.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.jeeplus.aop.logging.annotation.ApiLog;
|
|
|
import com.jeeplus.common.utils.ResponseUtil;
|
|
|
-import com.jeeplus.notify.service.NotifyService;
|
|
|
-import com.jeeplus.notify.service.dto.NotifyDTO;
|
|
|
import com.jeeplus.sys.service.OfficeService;
|
|
|
import com.jeeplus.sys.service.dto.OfficeDTO;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
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 com.jeeplus.test.wdt.disposeRubbish.domain.DisposeRubbish;
|
|
|
import com.jeeplus.test.wdt.disposeRubbish.service.DisposeRubbishService;
|
|
@@ -27,9 +21,7 @@ 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.*;
|
|
|
|
|
|
/**
|
|
|
* 清运处理
|
|
@@ -51,8 +43,7 @@ public class DisposeRubbishController {
|
|
|
@Autowired
|
|
|
private OssService ossService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private NotifyService notifyService;
|
|
|
+ private static final byte[] SYN_BYTE = new byte[0];
|
|
|
|
|
|
/**
|
|
|
* 查询巡视工单
|
|
@@ -71,15 +62,18 @@ public class DisposeRubbishController {
|
|
|
/**
|
|
|
* 查询巡视工单
|
|
|
*
|
|
|
- * @param id
|
|
|
+ * @param procInsIds
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("getByProcInsId")
|
|
|
- public ResponseEntity getByProcInsId(String procInsId) {
|
|
|
+ public ResponseEntity getByProcInsId(String procInsIds) {
|
|
|
+ // 转换为数组
|
|
|
+ String[] array = procInsIds.split(",");
|
|
|
+ // 再转换为集合(ArrayList)
|
|
|
+ List<String> procInsIdList = Arrays.asList(array);
|
|
|
// 还需要处理单位 清运专员 联系方式 及 附件信息
|
|
|
- DisposeRubbish post = disposeRubbishService.getByProcInsId ( procInsId );
|
|
|
-
|
|
|
- return ResponseEntity.ok ( post );
|
|
|
+ List<DisposeRubbish> getByProcInsId = disposeRubbishService.getByProcInsId ( procInsIdList );
|
|
|
+ return ResponseEntity.ok ( getByProcInsId );
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -89,48 +83,66 @@ public class DisposeRubbishController {
|
|
|
@ApiOperation(value = "保存巡视信息")
|
|
|
@PostMapping("save")
|
|
|
public ResponseEntity <String> save(@Valid @RequestBody DisposeRubbish disposeRubbish) {
|
|
|
- //新增或编辑表单保存
|
|
|
- if (StringUtils.isNotBlank(disposeRubbish.getNo())) {
|
|
|
- // 剔除掉XJ-J 只保留纯数字
|
|
|
- // 使用正则表达式替换掉所有非数字字符
|
|
|
- String pureNumber = disposeRubbish.getNo().replaceAll("\\D+", "");
|
|
|
- disposeRubbish.setNo(pureNumber);
|
|
|
- }
|
|
|
- if(disposeRubbish.getProgramIds().size()>0){
|
|
|
- String programIds = String.join(",", disposeRubbish.getProgramId());
|
|
|
- disposeRubbish.setProgramId(programIds);
|
|
|
- }
|
|
|
+ synchronized (SYN_BYTE) {
|
|
|
+ //新增或编辑表单保存
|
|
|
+ if (StringUtils.isBlank(disposeRubbish.getId())) {
|
|
|
+
|
|
|
+ // 获取第一条记录
|
|
|
+ DisposeRubbish noDisposeRubbish = disposeRubbishService.selectOne();
|
|
|
+ if (null != noDisposeRubbish) {
|
|
|
+ disposeRubbish.setYear(noDisposeRubbish.getYear());
|
|
|
+ Integer number = noDisposeRubbish.getNumber() + 1;
|
|
|
+ disposeRubbish.setNumber(number);
|
|
|
+ // 将年份和流水号拼接成 4 位数字的格式,不足 4 位补 0
|
|
|
+ String formattedNo = number < 10000 ? String.format("%d%04d", noDisposeRubbish.getYear(), number) : String.format("%d%d", noDisposeRubbish.getYear(), number);
|
|
|
+ disposeRubbish.setNo(formattedNo);
|
|
|
+ }else{
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ disposeRubbish.setYear(year);
|
|
|
+ Integer number = 1;
|
|
|
+ disposeRubbish.setNumber(number);
|
|
|
+ // 将年份和流水号拼接成 4 位数字的格式,不足 4 位补 0
|
|
|
+ String formattedNo = String.format("%d%04d", year, number);
|
|
|
+ disposeRubbish.setNo(formattedNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (disposeRubbish.getProgramIds().size() > 0) {
|
|
|
+ String programIds = String.join(",", disposeRubbish.getProgramId());
|
|
|
+ disposeRubbish.setProgramId(programIds);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- disposeRubbishService.saveOrUpdate (disposeRubbish);
|
|
|
+ disposeRubbishService.saveOrUpdate(disposeRubbish);
|
|
|
|
|
|
|
|
|
- //对过磅数据进行处理
|
|
|
- if (null != disposeRubbish.getFileList4() && disposeRubbish.getFileList4().size() > 0 ) {
|
|
|
- UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
- // 进行附件保存操作,保存到work_attachment 表中
|
|
|
- for (WorkAttachment attachment : disposeRubbish.getFileList4()) {
|
|
|
- // 生成id
|
|
|
- String detailId = SnowFlake.getId();
|
|
|
- attachment.setId(detailId);
|
|
|
- attachment.setAttachmentId(disposeRubbish.getId());
|
|
|
- attachment.setCreateTime(new Date());
|
|
|
- attachment.setUpdateTime(new Date());
|
|
|
- attachment.setDelFlag(0);
|
|
|
- attachment.setAttachmentFlag("weigh");
|
|
|
- ossService.insertWorkAttachment(attachment,userDTO);
|
|
|
+ //对过磅数据进行处理
|
|
|
+ if (null != disposeRubbish.getFileList4() && disposeRubbish.getFileList4().size() > 0 ) {
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ // 进行附件保存操作,保存到work_attachment 表中
|
|
|
+ for (WorkAttachment attachment : disposeRubbish.getFileList4()) {
|
|
|
+ // 生成id
|
|
|
+ String detailId = SnowFlake.getId();
|
|
|
+ attachment.setId(detailId);
|
|
|
+ attachment.setAttachmentId(disposeRubbish.getId());
|
|
|
+ attachment.setCreateTime(new Date());
|
|
|
+ attachment.setUpdateTime(new Date());
|
|
|
+ attachment.setDelFlag(0);
|
|
|
+ attachment.setAttachmentFlag("weigh");
|
|
|
+ ossService.insertWorkAttachment(attachment,userDTO);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- for (String workOverId : disposeRubbish.getProgramIds()) {
|
|
|
- LookOver lookOver = overService.getById(workOverId);
|
|
|
- //处理巡查单的状态信息,将巡查单的status调整为处理中
|
|
|
- if("2".equals(disposeRubbish.getStatus()) || "5".equals(disposeRubbish.getStatus())){
|
|
|
- lookOver.setStatus(disposeRubbish.getStatus());
|
|
|
- }else{
|
|
|
- lookOver.setStatus("1");
|
|
|
+ for (String workOverId : disposeRubbish.getProgramIds()) {
|
|
|
+ LookOver lookOver = overService.getById(workOverId);
|
|
|
+ //处理巡查单的状态信息,将巡查单的status调整为处理中
|
|
|
+ if("2".equals(disposeRubbish.getStatus()) || "5".equals(disposeRubbish.getStatus())){
|
|
|
+ lookOver.setStatus(disposeRubbish.getStatus());
|
|
|
+ }else{
|
|
|
+ lookOver.setStatus("1");
|
|
|
+ }
|
|
|
+ overService.updateStatus(lookOver);
|
|
|
}
|
|
|
- overService.updateStatus(lookOver);
|
|
|
}
|
|
|
return ResponseUtil.newInstance ( ).add("businessTable", "dispose_rubbish").add("businessId", disposeRubbish.getId()).ok ("保存成功");
|
|
|
}
|