From a5f40b4c2590a3d61592f1918d689d4932545248 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 22 一月 2025 15:06:38 +0800
Subject: [PATCH] ll
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java | 190 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 184 insertions(+), 6 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
index 2f9f45b..5aa6aef 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
@@ -12,9 +12,13 @@
import com.doumee.dao.business.YwDeviceMapper;
import com.doumee.dao.business.YwDeviceRecordMapper;
import com.doumee.dao.business.model.Category;
+import com.doumee.dao.business.model.Company;
import com.doumee.dao.business.model.YwDevice;
import com.doumee.dao.business.model.YwDeviceRecord;
+import com.doumee.dao.business.vo.YwDeviceCateDataVO;
import com.doumee.dao.business.vo.YwDeviceDataVO;
+import com.doumee.dao.business.vo.YwDeviceParentCateDataVO;
+import com.doumee.dao.business.vo.YwDeviceStatusDataVO;
import com.doumee.dao.system.MultifileMapper;
import com.doumee.dao.system.model.Multifile;
import com.doumee.dao.system.model.SystemUser;
@@ -32,9 +36,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -65,6 +67,10 @@
|| StringUtils.isBlank(ywDevice.getName())
|| StringUtils.isBlank(ywDevice.getCode())
|| Objects.isNull(ywDevice.getStatus())
+ || Objects.isNull(ywDevice.getProjectId())
+ || Objects.isNull(ywDevice.getFloorId())
+ || Objects.isNull(ywDevice.getBuildingId())
+ || Objects.isNull(ywDevice.getRoomId())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
@@ -86,6 +92,28 @@
multifile.setObjId(ywDevice.getId());
multifile.setFileurl(ywDevice.getFileUrl());
multifileMapper.insert(multifile);
+ }
+
+ List<Multifile> fileList = new ArrayList<>();
+ if(ywDevice.getMultifileList()!=null && ywDevice.getMultifileList().size()>0){
+ for (int i = 0; i < ywDevice.getMultifileList().size(); i++) {
+ Multifile multifile = ywDevice.getMultifileList().get(i);
+ if(StringUtils.isBlank(multifile.getFileurl())){
+ continue;
+ }
+ multifile.setCreateDate(ywDevice.getCreateDate());
+ multifile.setEditDate(ywDevice.getCreateDate());
+ multifile.setCreator(ywDevice.getEditor());
+ multifile.setIsdeleted(Constants.ZERO);
+ multifile.setObjId(ywDevice.getId());
+ multifile.setEditor(ywDevice.getCreator());
+ multifile.setObjType(Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey());
+ multifile.setSortnum(i+1);
+ fileList.add(multifile);
+ }
+ }
+ if(fileList.size()>0){
+ multifileMapper.insert(fileList);
}
return ywDevice.getId();
@@ -125,6 +153,10 @@
|| StringUtils.isBlank(ywDevice.getName())
|| StringUtils.isBlank(ywDevice.getCode())
|| Objects.isNull(ywDevice.getStatus())
+ || Objects.isNull(ywDevice.getProjectId())
+ || Objects.isNull(ywDevice.getFloorId())
+ || Objects.isNull(ywDevice.getBuildingId())
+ || Objects.isNull(ywDevice.getRoomId())
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
@@ -139,7 +171,7 @@
ywDeviceMapper.updateById(ywDevice);
multifileMapper.delete(new QueryWrapper<Multifile>().lambda()
.eq(Multifile::getObjId,ywDevice.getId())
- .eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE.getKey())
+ .in(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE.getKey(),Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey())
);
if(Objects.nonNull(ywDevice.getFileUrl())){
Multifile multifile = new Multifile();
@@ -150,6 +182,28 @@
multifile.setObjId(ywDevice.getId());
multifile.setFileurl(ywDevice.getFileUrl());
multifileMapper.insert(multifile);
+ }
+
+ List<Multifile> fileList = new ArrayList<>();
+ if(ywDevice.getMultifileList()!=null && ywDevice.getMultifileList().size()>0){
+ for (int i = 0; i < ywDevice.getMultifileList().size(); i++) {
+ Multifile multifile = ywDevice.getMultifileList().get(i);
+ if(StringUtils.isBlank(multifile.getFileurl())){
+ continue;
+ }
+ multifile.setCreateDate(ywDevice.getCreateDate());
+ multifile.setEditDate(ywDevice.getCreateDate());
+ multifile.setCreator(ywDevice.getEditor());
+ multifile.setIsdeleted(Constants.ZERO);
+ multifile.setObjId(ywDevice.getId());
+ multifile.setEditor(ywDevice.getCreator());
+ multifile.setObjType(Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey());
+ multifile.setSortnum(i+1);
+ fileList.add(multifile);
+ }
+ }
+ if(fileList.size()>0){
+ multifileMapper.insert(fileList);
}
@@ -180,8 +234,52 @@
+systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_DEVICE).getCode();
ywDevice.setFileFullUrl(path + multifile.getFileurl());
}
+
+ //闄勪欢鏁版嵁
+ List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>()
+ .selectAll(Multifile.class)
+ .selectAs(SystemUser::getRealname,Multifile::getUserName)
+ .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator)
+ .eq(Multifile::getObjId,ywDevice.getId())
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey()));
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
+ String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
+ +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_PATROL).getCode();
+ for (Multifile m:multifileList) {
+ if(StringUtils.isNotBlank(m.getFileurl())){
+ m.setFileurlFull(path + m.getFileurl());
+ }
+ }
+ ywDevice.setMultifileList(multifileList);
+ }
+
return ywDevice;
}
+
+
+ /**
+ * 鏍规嵁缂栫爜鏌ヨ
+ * @param deviceCode
+ * @return
+ */
+ @Override
+ public YwDevice findByCode(String deviceCode) {
+ YwDevice ywDevice = ywDeviceMapper.selectOne(
+ new QueryWrapper<YwDevice>()
+ .lambda()
+ .eq(YwDevice::getIsdeleted,Constants.ZERO)
+ .eq(YwDevice::getCode,deviceCode)
+ .last(" limit 1 ")
+ );
+ if(Objects.isNull(ywDevice)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+
+ return ywDevice;
+ }
+
+
@Override
@@ -203,12 +301,18 @@
Utils.MP.blankToNull(pageWrap.getModel());
YwDevice model = pageWrap.getModel();
queryWrapper.selectAll(YwDevice.class)
- .selectAs(Category::getName,YwDevice::getCategoryName)
+ .select("c.name",YwDevice::getCategoryName)
+ .select("c1.name",YwDevice::getCategoryParentName)
.selectAs(SystemUser::getRealname,YwDevice::getRealName)
- .leftJoin(Category.class,Category::getId,YwDevice::getCateId)
.leftJoin(SystemUser.class,SystemUser::getId,YwDevice::getUserId)
+ .leftJoin("category c on t.CATE_ID = c.id")
+ .leftJoin("category c1 on c.PARENT_ID = c1.id")
.and(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getName()),i->i.like(YwDevice::getName,model.getName()).or().like(YwDevice::getCode,model.getName()))
.eq(Objects.nonNull(model.getStatus()),YwDevice::getStatus,model.getStatus())
+ .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
+ .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
+ .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
+ .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
.eq(YwDevice::getIsdeleted,Constants.ZERO)
.orderByDesc(YwDevice::getCreateDate)
;
@@ -238,6 +342,80 @@
return ywDeviceDataVO;
}
+ @Override
+ public Set<YwDeviceCateDataVO> getDeviceCateData(YwDevice model){
+ MPJLambdaWrapper<YwDevice> queryWrapper = new MPJLambdaWrapper<YwDevice>();
+ queryWrapper.selectAll(YwDevice.class)
+ .select("c.name",YwDevice::getCategoryName)
+ .select("c1.name",YwDevice::getCategoryParentName)
+ .select("c1.id",YwDevice::getCateParentId)
+ .selectAs(SystemUser::getRealname,YwDevice::getRealName)
+ .leftJoin(SystemUser.class,SystemUser::getId,YwDevice::getUserId)
+ .leftJoin("category c on t.CATE_ID = c.id")
+ .leftJoin("category c1 on c.PARENT_ID = c1.id")
+ .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
+ .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
+ .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
+ .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
+ .eq(YwDevice::getIsdeleted,Constants.ZERO)
+ .isNotNull(YwDevice::getCateId)
+ .orderByDesc(YwDevice::getCreateDate)
+ ;
+ List<YwDevice> ywDeviceList = ywDeviceMapper.selectJoinList(YwDevice.class,queryWrapper);
+ Set<YwDeviceCateDataVO> ywDeviceCateDataVOSet = new HashSet<>();
+ Set<YwDeviceParentCateDataVO> ywDeviceParentCateDataVOSet = new HashSet<>();
+ for (YwDevice y: ywDeviceList) {
+ YwDeviceCateDataVO ywDeviceCateDataVO = new YwDeviceCateDataVO();
+ ywDeviceCateDataVO.setCateId(y.getCateId());
+ ywDeviceCateDataVO.setCateName(y.getCategoryName());
+ ywDeviceCateDataVO.setCateParentId(y.getCateParentId());
+ ywDeviceCateDataVOSet.add(ywDeviceCateDataVO);
+ YwDeviceParentCateDataVO ywDeviceParentCateDataVO = new YwDeviceParentCateDataVO();
+ ywDeviceParentCateDataVO.setCateId(y.getCateParentId());
+ ywDeviceParentCateDataVO.setCateName(y.getCategoryParentName());
+ ywDeviceParentCateDataVOSet.add(ywDeviceParentCateDataVO);
+ }
+
+ for (YwDeviceCateDataVO ywDeviceCateDataVO:ywDeviceCateDataVOSet) {
+ ywDeviceCateDataVO.setDeviceAmount(
+ ywDeviceList.stream().filter(i->Objects.nonNull(i.getCateId()) && Constants.equalsInteger(i.getCateId(),ywDeviceCateDataVO.getCateId())).collect(Collectors.toList()).size()
+ );
+ }
+
+ for (YwDeviceParentCateDataVO ywDeviceParentCateDataVO:ywDeviceParentCateDataVOSet) {
+ ywDeviceParentCateDataVO.setDeviceAmount(
+ ywDeviceList.stream().filter(i->Objects.nonNull(i.getCateParentId()) && Constants.equalsInteger(i.getCateParentId(),ywDeviceParentCateDataVO.getCateId())).collect(Collectors.toList()).size()
+ );
+ ywDeviceParentCateDataVO.setYwDeviceCateDataVOList(
+ ywDeviceCateDataVOSet.stream().filter(i->Constants.equalsInteger(i.getCateParentId(),ywDeviceParentCateDataVO.getCateId())).collect(Collectors.toList())
+ );
+ }
+ return ywDeviceCateDataVOSet;
+ }
+
+
+ @Override
+ public YwDeviceStatusDataVO getDeviceStatus(YwDevice model){
+ YwDeviceStatusDataVO ywDeviceStatusDataVO = new YwDeviceStatusDataVO();
+ MPJLambdaWrapper<YwDevice> queryWrapper = new MPJLambdaWrapper<YwDevice>();
+ queryWrapper.selectAll(YwDevice.class)
+ .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
+ .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
+ .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
+ .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
+ .eq(YwDevice::getIsdeleted,Constants.ZERO)
+ ;
+ List<YwDevice> ywDeviceList = ywDeviceMapper.selectJoinList(YwDevice.class,queryWrapper);
+ ywDeviceStatusDataVO.setAmount(ywDeviceList.size());
+ ywDeviceStatusDataVO.setWorkAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.ZERO)).collect(Collectors.toList()).size());
+ ywDeviceStatusDataVO.setExceptionAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.ONE)).collect(Collectors.toList()).size());
+ ywDeviceStatusDataVO.setErrAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.THREE)).collect(Collectors.toList()).size());
+ return ywDeviceStatusDataVO;
+
+ }
+
+
+
}
--
Gitblit v1.9.3