|
|
@@ -0,0 +1,108 @@
|
|
|
+package tr.cn.module.phototherapy.common.service.impl;
|
|
|
+
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import cn.tr.core.exception.ServiceException;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import tr.cn.module.phototherapy.common.repository.BusDeviceHistoryRepository;
|
|
|
+import tr.cn.module.phototherapy.common.po.BusDeviceHistoryPO;
|
|
|
+import tr.cn.module.phototherapy.common.dto.BusDeviceHistoryDTO;
|
|
|
+import tr.cn.module.phototherapy.common.dto.BusDeviceHistoryQueryDTO;
|
|
|
+import java.util.*;
|
|
|
+import tr.cn.module.phototherapy.common.service.IBusDeviceHistoryService;
|
|
|
+import tr.cn.module.phototherapy.common.mapper.BusDeviceHistoryMapper;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import cn.tr.core.exception.TRExcCode;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设备历史Service接口实现类
|
|
|
+ *
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+public class BusDeviceHistoryServiceImpl implements IBusDeviceHistoryService {
|
|
|
+ @Resource
|
|
|
+ private BusDeviceHistoryRepository baseRepository;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据条件查询设备历史
|
|
|
+ * @param query 查询参数
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BusDeviceHistoryDTO> selectBusDeviceHistoryList(BusDeviceHistoryQueryDTO query){
|
|
|
+ return BusDeviceHistoryMapper.INSTANCE.convertDtoList(
|
|
|
+ baseRepository.selectList(new LambdaQueryWrapper<BusDeviceHistoryPO>()
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getId()), BusDeviceHistoryPO::getId, query.getId())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getDeviceId()), BusDeviceHistoryPO::getDeviceId, query.getDeviceId())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getPatientUniqueId()), BusDeviceHistoryPO::getPatientUniqueId, query.getPatientUniqueId())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTherapyId()), BusDeviceHistoryPO::getTherapyId, query.getTherapyId())
|
|
|
+ .like(ObjectUtil.isNotNull(query.getClassification()), BusDeviceHistoryPO::getClassification, query.getClassification())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getDataNumber()), BusDeviceHistoryPO::getDataNumber, query.getDataNumber())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTherapyStartTime()), BusDeviceHistoryPO::getTherapyStartTime, query.getTherapyStartTime())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTherapyEndTime()), BusDeviceHistoryPO::getTherapyEndTime, query.getTherapyEndTime())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTherapyDuration()), BusDeviceHistoryPO::getTherapyDuration, query.getTherapyDuration())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getUploadTime()), BusDeviceHistoryPO::getUploadTime, query.getUploadTime())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getRunState()), BusDeviceHistoryPO::getRunState, query.getRunState())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getAlarmState()), BusDeviceHistoryPO::getAlarmState, query.getAlarmState())
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getWarnLowBattery()), BusDeviceHistoryPO::getWarnLowBattery, query.getWarnLowBattery())
|
|
|
+ .like(ObjectUtil.isNotNull(query.getAlarmDesc()), BusDeviceHistoryPO::getAlarmDesc, query.getAlarmDesc())
|
|
|
+ )
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询设备历史
|
|
|
+ * @param id 主键id
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BusDeviceHistoryDTO selectBusDeviceHistoryById(Long id){
|
|
|
+ return BusDeviceHistoryMapper.INSTANCE.convertDto(baseRepository.selectById(id));
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑设备历史
|
|
|
+ * @param source 编辑实体类
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public boolean updateBusDeviceHistoryById(BusDeviceHistoryDTO source){
|
|
|
+ return baseRepository.updateById(BusDeviceHistoryMapper.INSTANCE.convertPO(source))!=0;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增设备历史
|
|
|
+ * @param source 新增实体类
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean insertBusDeviceHistory(BusDeviceHistoryDTO source){
|
|
|
+ return baseRepository.insert(BusDeviceHistoryMapper.INSTANCE.convertPO(source))!=0;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除设备历史详情
|
|
|
+ * @param ids 删除主键集合
|
|
|
+ * @author CodeGenerator
|
|
|
+ * @date 2026-01-13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int removeBusDeviceHistoryByIds(Collection<Long> ids){
|
|
|
+ if(CollectionUtil.isEmpty(ids)){
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
|
|
|
+ }
|
|
|
+ return baseRepository.deleteByIds(ids);
|
|
|
+ };
|
|
|
+}
|