浏览代码

controller优化

guarantee-lsq 1 年之前
父节点
当前提交
66b36d27c7

+ 9 - 17
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -12,17 +12,11 @@ import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
 import com.platform.dao.dto.sb.SbChangeRecordDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
-import com.platform.dao.dto.sb.SbMeasureLogDTO;
 import com.platform.dao.dto.sb.SbModelSpareBomDTO;
 import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbMeasureLog;
-import com.platform.dao.entity.sb.SbModelSpareBom;
-import com.platform.dao.entity.sb.SbType;
 import com.platform.dao.enums.SbMeasureLogOtherTypeEnum;
 import com.platform.dao.enums.SysRoleCodeEnum;
-import com.platform.dao.mapper.sb.SbInfoMapper;
-import com.platform.dao.mapper.sb.SbMeasureLogMapper;
-import com.platform.dao.mapper.sb.SbTypeMapper;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.util.TreeUtil;
 import com.platform.dao.vo.export.sb.ExportSbInfoDetailVO;
@@ -31,16 +25,16 @@ import com.platform.dao.vo.export.sb.ExportSbInfoVO;
 import com.platform.dao.vo.export.sb.ExportYiBiaoSbInfoVO;
 import com.platform.dao.vo.sb.SbInfoVO;
 import com.platform.dao.vo.sb.SbInfoWorkplaceVO;
-import com.platform.dao.vo.sb.SbTypeVO;
 import com.platform.office.poi.excel.ExcelImportUtil;
 import com.platform.office.poi.excel.entity.ImportParams;
 import com.platform.rest.log.annotation.SysLog;
 import com.platform.service.fill.FillGatherTaskService;
 import com.platform.service.sb.SbInfoService;
+import com.platform.service.sb.SbMeasureLogService;
+import com.platform.service.sb.SbTypeService;
 import com.platform.service.upms.SysUserRoleService;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -67,10 +61,8 @@ public class SbInfoController {
     private final SbInfoService sbInfoService;
     private final SysUserRoleService sysUserRoleService;
     private final FillGatherTaskService fillGatherTaskService;
-    private final SbInfoMapper sbInfoMapper;
-    private final SbTypeMapper sbTypeMapper;
-    private final SbMeasureLogMapper sbMeasureLogMapper;
-
+    private final SbMeasureLogService sbMeasureLogService;
+    private final SbTypeService sbTypeService;
     /**
      * 设备工作台数据
      *
@@ -268,7 +260,7 @@ public class SbInfoController {
         SbInfoDTO dto = new SbInfoDTO();
         dto.setSbIds(ids);
         dto.setUseType(4);
-        List<SbInfoVO> sbInfoVOS = sbInfoMapper.selectVOList(dto);
+        List<SbInfoVO> sbInfoVOS = sbInfoService.selectVOList(dto);
         sbInfoService.batchDelete(ids);
 
         List<SbMeasureLog> measureLogs = new ArrayList<>();
@@ -286,7 +278,7 @@ public class SbInfoController {
                 log.setContent(str);
                 measureLogs.add(log);
             }
-            sbMeasureLogMapper.insertListforComplex(measureLogs);
+            sbMeasureLogService.saveModelList(measureLogs);
         }
         return new R<>();
     }
@@ -638,10 +630,10 @@ public class SbInfoController {
         if (sbInfoDTO.getTypeId()!=null&&sbInfoDTO.getTypeId().equals("特种设备")){
             SbInfoDTO sbInfoDTO1 = new SbInfoDTO();
             sbInfoDTO1.setUseType(5);
-            List<SbInfoVO> sbInfoVOS = sbInfoMapper.selectVOList(sbInfoDTO1);
+            List<SbInfoVO> sbInfoVOS = sbInfoService.selectVOList(sbInfoDTO1);
             ExcelUtil.exportResponseDict(response, ExportSbInfoDetailVO.class, BeanConverterUtil.copyListProperties(sbInfoVOS, ExportSbInfoDetailVO.class), "设备基础信息");
         }else {
-            SbType type = sbTypeMapper.selectById(sbInfoDTO.getTypeId());
+            //SbType type = sbTypeService.getModelById(sbInfoDTO.getTypeId());
             List<SbInfoVO> list = new ArrayList<>();
 //        if (type!=null&&type.getParentId()!=null) {
             List<String> ids = new ArrayList<>();
@@ -664,7 +656,7 @@ public class SbInfoController {
 
     private List<String> getSbIds(List<String> ids){
         if (ids!=null&&ids.size()>0) {
-            List<String> childIds = sbInfoMapper.getChildIds(ids);
+            List<String> childIds = sbInfoService.getChildIds(ids);
             ids.addAll(childIds);
             if (childIds!=null&&childIds.size()>0){
                getSbIds(childIds);

+ 3 - 0
platform-service/src/main/java/com/platform/service/sb/SbInfoService.java

@@ -356,4 +356,7 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
      * @return
      */
     Integer getRepairProfessorBySbId(String id);
+
+    List<String> getChildIds(List<String> ids);
+
 }

+ 5 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -3679,4 +3679,9 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         }
         return null;
     }
+
+    @Override
+    public List<String> getChildIds(List<String> ids) {
+        return mapper.getChildIds(ids);
+    }
 }