|
|
@@ -1,16 +1,21 @@
|
|
|
-package com.zhongshu.card.server.core.service.org;
|
|
|
+package com.zhongshu.card.server.core.service.devices;
|
|
|
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.models.device.DeviceInfoSyncParam;
|
|
|
-import com.zhongshu.card.client.model.school.*;
|
|
|
+import com.zhongshu.card.client.model.devices.*;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationMiniModel;
|
|
|
import com.zhongshu.card.client.service.school.DeviceInfoService;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.dao.school.AreaDao;
|
|
|
import com.zhongshu.card.server.core.dao.school.DeviceInfoDao;
|
|
|
import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.school.Area;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.school.AreaServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -49,6 +54,9 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
|
|
|
@Autowired
|
|
|
OrganizationDao organizationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrganizationManagerServiceImpl organizationManagerService;
|
|
|
+
|
|
|
/**
|
|
|
* 同步设备 (设备基础信息)
|
|
|
*
|
|
|
@@ -68,6 +76,7 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, deviceInfo, "id");
|
|
|
deviceInfo.setProjectInfoName(organizationServiceImpl.getOrgNameByCode(param.getProjectInfoCode()));
|
|
|
+
|
|
|
deviceInfoDao.save(deviceInfo);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -104,7 +113,13 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent<Page<DeviceInfoModel>> page(DeviceInfoSearch param, Pageable pageable) {
|
|
|
- initOidSearchParam(param);
|
|
|
+ // 完善所属项目
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
+ Organization organization = organizationDao.findTopByOid(projectOid);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildFail("projectOid不存在");
|
|
|
+ }
|
|
|
+ param.setProjectInfoCode(organization.getCode());
|
|
|
Page<DeviceInfo> page = deviceInfoDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
@@ -173,6 +188,33 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent updateDevice(DeviceBindAreaParam param) {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
+ }
|
|
|
+ // 修改设备 只能绑定 区域 所属机构等信息
|
|
|
+ if (StringUtils.isNotEmpty(deviceInfo.getDeviceId())) {
|
|
|
+ Area area = areaDao.findTopById(param.getAreaId());
|
|
|
+ if (ObjectUtils.isEmpty(area)) {
|
|
|
+ return ResultContent.buildFail("区域信息不存在");
|
|
|
+ }
|
|
|
+ deviceInfo.setArea(area);
|
|
|
+ }
|
|
|
+
|
|
|
+ Organization organization = null;
|
|
|
+ if (StringUtils.isNotEmpty(param.getOid())) {
|
|
|
+ organization = organizationDao.findTopByOid(param.getOid());
|
|
|
+ }
|
|
|
+ deviceInfo.setOrganization(organization);
|
|
|
+ deviceInfoDao.save(deviceInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设备基础信息
|
|
|
*
|
|
|
@@ -184,6 +226,10 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = new DeviceInfoModel();
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+ model.setProjectInfoName(organizationServiceImpl.getOrgNameByCode(entity.getProjectInfoCode()));
|
|
|
+
|
|
|
+ OrganizationMiniModel miniModel = organizationManagerService.toMiniModel(entity.getOrganization());
|
|
|
+ model.setOrganization(miniModel);
|
|
|
}
|
|
|
return model;
|
|
|
}
|