|
|
@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
-import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummarySaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
|
|
|
@@ -13,13 +12,15 @@ import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSourceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSummaryMapper;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
|
@@ -38,19 +39,29 @@ public class IotSocSummaryServiceImpl implements IotSocSummaryService {
|
|
|
private DeptApi deptApi;
|
|
|
@Autowired
|
|
|
private IotSocSourceMapper iotSocSourceMapper;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@Override
|
|
|
public Long createIotSocSummary(IotSocSummarySaveReqVO createReqVO) {
|
|
|
// 插入
|
|
|
IotSocSummaryDO iotSocSummary = BeanUtils.toBean(createReqVO, IotSocSummaryDO.class);
|
|
|
- Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
- String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
|
- iotSocSummary.setUserName(loginUserNickname);
|
|
|
- if (Objects.nonNull(loginUserDeptId)) {
|
|
|
- iotSocSummary.setDeptId(loginUserDeptId);
|
|
|
- DeptRespDTO dept = deptApi.getDept(loginUserDeptId);
|
|
|
+// Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
+// String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
|
+ iotSocSummary.setUserName(createReqVO.getUserName());
|
|
|
+ if (Objects.nonNull(createReqVO.getDeptId())) {
|
|
|
+ iotSocSummary.setDeptId(createReqVO.getDeptId());
|
|
|
+ DeptRespDTO dept = deptApi.getDept(createReqVO.getDeptId());
|
|
|
if (Objects.isNull(dept)) {throw new ServiceException(new ErrorCode(3,"不存在"));}
|
|
|
iotSocSummary.setDeptName(dept.getName());
|
|
|
+ Long parentId = dept.getParentId();
|
|
|
+ if (Objects.nonNull(parentId)) {
|
|
|
+ DeptRespDTO dept1 = deptApi.getDept(parentId);
|
|
|
+ if (Objects.nonNull(dept1)) {
|
|
|
+ iotSocSummary.setProject(parentId);
|
|
|
+ iotSocSummary.setProjectName(dept1.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (Objects.nonNull(iotSocSummary.getSocClass())) {
|
|
|
IotSocSourceDO iotSocSourceDO = iotSocSourceMapper.selectById(iotSocSummary.getSocClass());
|
|
|
@@ -93,7 +104,12 @@ public class IotSocSummaryServiceImpl implements IotSocSummaryService {
|
|
|
|
|
|
@Override
|
|
|
public PageResult<IotSocSummaryDO> getIotSocSummaryPage(IotSocSummaryPageReqVO pageReqVO) {
|
|
|
- return iotSocSummaryMapper.selectPage(pageReqVO);
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (Objects.nonNull(pageReqVO.getDeptId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ }
|
|
|
+ return iotSocSummaryMapper.selectPage(pageReqVO, ids);
|
|
|
}
|
|
|
|
|
|
}
|