提交 c2559c82 authored 作者: zhoushaopan's avatar zhoushaopan

fix(装备模块,3d模块): 新增查询全部3D的接口。以及日志打印时间

新增查询全部3D的接口。以及日志打印时间
上级 09ac5319
...@@ -4,6 +4,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition; ...@@ -4,6 +4,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition;
import com.tykj.dev.device.library.subject.model.vo.UpdatePostionMessageVO; import com.tykj.dev.device.library.subject.model.vo.UpdatePostionMessageVO;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author zsp * @author zsp
...@@ -69,4 +70,6 @@ public interface DeviceLibraryPositionService { ...@@ -69,4 +70,6 @@ public interface DeviceLibraryPositionService {
void fnUpdatePostionMessageList(UpdatePostionMessageVO updatePostionMessageVO); void fnUpdatePostionMessageList(UpdatePostionMessageVO updatePostionMessageVO);
List<DeviceLibraryPosition> findAll();
} }
package com.tykj.dev.device.library.service.impl; package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.config.Log;
import com.tykj.dev.device.library.repository.DeviceLibraryPositionDao; import com.tykj.dev.device.library.repository.DeviceLibraryPositionDao;
import com.tykj.dev.device.library.service.DeviceLibraryPositionService; import com.tykj.dev.device.library.service.DeviceLibraryPositionService;
import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition; import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition;
import com.tykj.dev.device.library.subject.model.vo.UpdatePostionMessageVO; import com.tykj.dev.device.library.subject.model.vo.UpdatePostionMessageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -16,6 +21,7 @@ import java.util.stream.Collectors; ...@@ -16,6 +21,7 @@ import java.util.stream.Collectors;
* @create 2021/12/13 16:23 * @create 2021/12/13 16:23
*/ */
@Service @Service
@Slf4j
public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionService { public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionService {
@Autowired @Autowired
...@@ -85,4 +91,14 @@ public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionSe ...@@ -85,4 +91,14 @@ public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionSe
deviceLibraryPositionDao.fnUpdatePostionMessageList(json, json1,updatePostionMessageVO.getUNum(), deviceIds); deviceLibraryPositionDao.fnUpdatePostionMessageList(json, json1,updatePostionMessageVO.getUNum(), deviceIds);
} }
@Override
public List<DeviceLibraryPosition> findAll() {
StopWatch stopWatch = new StopWatch("查询3D库的时间");
stopWatch.start();
List<DeviceLibraryPosition> deviceLibraryPositionList = deviceLibraryPositionDao.findAll();
stopWatch.stop();
log.info("查询3D库的时间:{}",stopWatch.getTotalTimeMillis()+"ms");
return deviceLibraryPositionList;
}
} }
...@@ -1327,10 +1327,16 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -1327,10 +1327,16 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
stopWatch1.start(); stopWatch1.start();
StopWatch stopWatch2 = new StopWatch("转换map"); StopWatch stopWatch2 = new StopWatch("转换map");
stopWatch2.start(); stopWatch2.start();
Map<Integer, DeviceLibraryPosition> positionMap = // Map<Integer, DeviceLibraryPosition> positionMap =
deviceLibraryPositionService.findByDeviceIds(deviceIds).stream() // deviceLibraryPositionService.findByDeviceIds(deviceIds).stream()
.collect(toMap(DeviceLibraryPosition::getDeviceId, Function.identity())); // .collect(toMap(DeviceLibraryPosition::getDeviceId, Function.identity()));
List<DeviceLibraryPosition> deviceLibraryPositionList = deviceLibraryPositionService.findAll();
deviceLibraryPositionList = deviceLibraryPositionList.stream().filter(deviceLibraryPosition -> deviceIds.contains(deviceLibraryPosition.getDeviceId()))
.collect(Collectors.toList());
stopWatch2.stop(); stopWatch2.stop();
Map<Integer, DeviceLibraryPosition> positionMap =
deviceLibraryPositionList.stream().collect(toMap(DeviceLibraryPosition::getDeviceId,
Function.identity()));
log.info("转换map的时间:{}",stopWatch2.getTotalTimeMillis()+"ms"); log.info("转换map的时间:{}",stopWatch2.getTotalTimeMillis()+"ms");
StopWatch stopWatch3 = new StopWatch("转换json"); StopWatch stopWatch3 = new StopWatch("转换json");
stopWatch3.start(); stopWatch3.start();
...@@ -1380,6 +1386,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -1380,6 +1386,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
if(queryTheWarehouseVo.getStorageLocationId() != null){ if(queryTheWarehouseVo.getStorageLocationId() != null){
map.put("pageAllVo",pageAllVo); map.put("pageAllVo",pageAllVo);
} }
StopWatch stopWatch4 = new StopWatch("返回结果集map");
stopWatch4.start();
List<DeviceLibrary> collect = pageAllVo.stream().map(AllVO::getDeviceLibrary).collect(Collectors.toList()); List<DeviceLibrary> collect = pageAllVo.stream().map(AllVO::getDeviceLibrary).collect(Collectors.toList());
List<String> models = List<String> models =
collect.stream().map(DeviceLibrary::getModel).distinct().collect(Collectors.toList()); collect.stream().map(DeviceLibrary::getModel).distinct().collect(Collectors.toList());
...@@ -1397,6 +1405,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -1397,6 +1405,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
map.put("ownUnits",ownUnits); map.put("ownUnits",ownUnits);
map.put("storageLocation",storageLocationIds.stream().map(integer -> new StorageLocationVo(integer,idMap.getOrDefault(integer,null))) map.put("storageLocation",storageLocationIds.stream().map(integer -> new StorageLocationVo(integer,idMap.getOrDefault(integer,null)))
.collect(Collectors.toList())); .collect(Collectors.toList()));
stopWatch4.stop();
log.info("返回结果集map时间:{}",stopWatch4.getTotalTimeMillis()+"ms");
return map; return map;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论