|
|
@ -21,9 +21,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.MonitoringDTO; |
|
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.modules.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.modules.security.dao.MonitoringDao; |
|
|
|
import com.elink.esua.epdc.modules.security.entity.MonitoringEntity; |
|
|
|
import com.elink.esua.epdc.modules.security.redis.MonitoringRedis; |
|
|
@ -49,13 +53,19 @@ public class MonitoringServiceImpl extends BaseServiceImpl<MonitoringDao, Monito |
|
|
|
@Autowired |
|
|
|
private MonitoringRedis monitoringRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<MonitoringDTO> page(Map<String, Object> params) { |
|
|
|
IPage<MonitoringEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, MonitoringDTO.class); |
|
|
|
// IPage<MonitoringEntity> page = baseDao.selectPage(
|
|
|
|
// getPage(params, FieldConstant.CREATED_TIME, false),
|
|
|
|
// getWrapper(params)
|
|
|
|
// );
|
|
|
|
// return getPageData(page, MonitoringDTO.class);
|
|
|
|
IPage<MonitoringDTO> page = getPage(params); |
|
|
|
List<MonitoringDTO> list = baseDao.getPageList(params); |
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -76,14 +86,26 @@ public class MonitoringServiceImpl extends BaseServiceImpl<MonitoringDao, Monito |
|
|
|
|
|
|
|
@Override |
|
|
|
public MonitoringDTO get(String id) { |
|
|
|
MonitoringEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, MonitoringDTO.class); |
|
|
|
MonitoringDTO result = baseDao.selectDetailById(id); |
|
|
|
result.setAllDeptIdsShow(Arrays.asList(result.getAllDeptIds().split(","))); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(MonitoringDTO dto) { |
|
|
|
MonitoringEntity entity = ConvertUtils.sourceToTarget(dto, MonitoringEntity.class); |
|
|
|
Result<ParentAndAllDeptDTO> parentResult = adminFeignClient.getParentAndAllDept(dto.getDeptId()); |
|
|
|
if (!parentResult.success() || parentResult.getData() == null) { |
|
|
|
throw new RenException("获取部门信息失败"); |
|
|
|
} else { |
|
|
|
ParentAndAllDeptDTO deptDTO = parentResult.getData(); |
|
|
|
entity.setDeptName(deptDTO.getGrid()); |
|
|
|
entity.setAllDeptIds(deptDTO.getAllDeptIds()); |
|
|
|
entity.setAllDeptNames(deptDTO.getAllDeptNames()); |
|
|
|
entity.setParentDeptIds(deptDTO.getParentDeptIds()); |
|
|
|
entity.setParentDeptNames(deptDTO.getParentDeptNames()); |
|
|
|
} |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
@ -91,6 +113,17 @@ public class MonitoringServiceImpl extends BaseServiceImpl<MonitoringDao, Monito |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(MonitoringDTO dto) { |
|
|
|
MonitoringEntity entity = ConvertUtils.sourceToTarget(dto, MonitoringEntity.class); |
|
|
|
Result<ParentAndAllDeptDTO> parentResult = adminFeignClient.getParentAndAllDept(dto.getDeptId()); |
|
|
|
if (!parentResult.success() || parentResult.getData() == null) { |
|
|
|
throw new RenException("获取部门信息失败"); |
|
|
|
} else { |
|
|
|
ParentAndAllDeptDTO deptDTO = parentResult.getData(); |
|
|
|
entity.setDeptName(deptDTO.getGrid()); |
|
|
|
entity.setAllDeptIds(deptDTO.getAllDeptIds()); |
|
|
|
entity.setAllDeptNames(deptDTO.getAllDeptNames()); |
|
|
|
entity.setParentDeptIds(deptDTO.getParentDeptIds()); |
|
|
|
entity.setParentDeptNames(deptDTO.getParentDeptNames()); |
|
|
|
} |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|