Browse Source

保养标准1:导入预览
2:以设备维度查询它所有的标准

hfxc226 1 year ago
parent
commit
f2c4336299

+ 25 - 1
platform-rest/src/main/java/com/platform/rest/controller/check/CheckStandardController.java

@@ -23,6 +23,7 @@ import com.platform.rest.log.annotation.SysLog;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -104,6 +105,30 @@ public class CheckStandardController {
         return new R<>();
     }
 
+
+    /**
+     * 查询某个设备的所有保养
+     *
+     * @param sbId 设备id
+     * @return R
+     */
+    @GetMapping("/sb/{sbId}")
+    public R<CheckStandardBatchDTO> getBySbId(@PathVariable("sbId") String sbId) {
+        return new R<>(checkStandardService.getBatchBySbId(sbId));
+    }
+
+    /**
+     * 导入保养标准预览, 在系统页面直接展示(包括修改,新增,删除),页面上面修改后再整体提交
+     *
+     * @param
+     * @return R
+     */
+    @SysLog("新增导入设备的保养标准")
+    @PostMapping("/import/review")
+    public R importReview(@RequestParam("file") MultipartFile file) throws IOException {
+        return new R(checkStandardService.importReview(file));
+    }
+
     /**
      * 初始化编码
      *
@@ -242,7 +267,6 @@ public class CheckStandardController {
         return new R();
     }
 
-
     @SysLog("导入设备的保养标准")
     @PostMapping(value = "/import", headers = "content-type=multipart/form-data")
     public R importListByAdd(@RequestParam("files") MultipartFile[] files) throws Exception {

+ 4 - 0
platform-service/src/main/java/com/platform/service/check/CheckStandardService.java

@@ -81,4 +81,8 @@ public interface CheckStandardService extends IBaseService<CheckStandard, CheckS
      * @return :
      */
     AbstractPageResultBean<CheckStandardSpareVO> selectSpareWarnVOPage(int month, int type, int pageNum, int pageSize);
+
+    CheckStandardBatchDTO getBatchBySbId(String sbId);
+
+    CheckStandardBatchDTO importReview(MultipartFile file) throws IOException;
 }

+ 54 - 0
platform-service/src/main/java/com/platform/service/check/impl/CheckStandardServiceImpl.java

@@ -133,6 +133,12 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
         return mapper.selectProjectStandardList(projectId);
     }
 
+    /**
+     * 查询list,不包含图片和文件的
+     *
+     * @param record
+     * @return
+     */
     @Override
     public List<CheckStandardVO> selectList(CheckStandardDTO record) {
         List<CheckStandardVO> voList = mapper.selectList(record);
@@ -747,6 +753,54 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
         return null;
     }
 
+    /**
+     * 一次只能导入一个设备的
+     * 1:可以修改:id存在
+     * 2:可以删除:数据库查询出来的不在excel里面了
+     * 3:可以新增:id =null
+     *
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public CheckStandardBatchDTO importReview(MultipartFile file) throws IOException {
+        List<ExportCheckStandardVO2> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO2.class, 1);
+
+        List<String> sbNoList = list.stream().map(item -> item.getSbNo()).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(sbNoList) && sbNoList.size() > 1) {
+            sbNoList = sbNoList.stream().distinct().collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(sbNoList) && sbNoList.size() > 1) {
+                throw new BusinessException("一次只能导致一个设备的标准");
+            }
+        }
+
+        SbInfo sbInfo = BeanConverterUtil.copyObjectProperties(sbInfoMapper.getByNo(sbNoList.get(0)), SbInfo.class);
+
+        List<CheckStandardDTO> checkStandardDTOS = BeanConverterUtil.copyListProperties(list, CheckStandardDTO.class);
+        CheckStandardBatchDTO checkStandardBatchDTO = new CheckStandardBatchDTO();
+        checkStandardBatchDTO.setSbId(sbInfo.getId());
+        checkStandardBatchDTO.setList(checkStandardDTOS);
+        return checkStandardBatchDTO;
+    }
+
+    /**
+     * 查询某个设备的保养标准列表:不带文件?
+     *
+     * @param sbId
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public CheckStandardBatchDTO getBatchBySbId(String sbId){
+        CheckStandardBatchDTO checkStandardBatchDTO = new CheckStandardBatchDTO();
+        checkStandardBatchDTO.setSbId(sbId);
+        CheckStandardDTO record = new CheckStandardDTO();
+        record.setSbId(sbId);
+        List<CheckStandardVO> list = selectList(record);
+        checkStandardBatchDTO.setList(BeanConverterUtil.copyListProperties(list, CheckStandardDTO.class));
+        return checkStandardBatchDTO;
+    }
     /**
      * 一次批量修改或者新增一个设备的保养标准
      * 1:可以修改:id存在