DebugFaultService.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.ruoyi.sim.service.impl;
  2. import java.util.List;
  3. import com.ruoyi.common.utils.DateUtils;
  4. import com.ruoyi.sim.domain.Fault;
  5. import com.ruoyi.sim.domain.Sim;
  6. import org.apache.commons.lang3.StringUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import com.ruoyi.sim.mapper.DebugFaultMapper;
  10. import com.ruoyi.sim.domain.DebugFault;
  11. /**
  12. * 调试故障Service业务层处理
  13. *
  14. * @author tom
  15. * @date 2025-02-10
  16. */
  17. @Service
  18. public class DebugFaultService {
  19. @Autowired
  20. private DebugFaultMapper debugFaultMapper;
  21. /**
  22. * 查询调试故障
  23. *
  24. * @param refId 调试故障主键
  25. * @return 调试故障
  26. */
  27. public DebugFault selectDebugFaultByRefId(Long refId) {
  28. return debugFaultMapper.selectDebugFaultByRefId(refId);
  29. }
  30. /**
  31. * 查询调试故障列表
  32. *
  33. * @param debugFault 调试故障
  34. * @return 调试故障
  35. */
  36. public List<DebugFault> selectDebugFaultList(DebugFault debugFault) {
  37. return debugFaultMapper.selectDebugFaultList(debugFault);
  38. }
  39. /**
  40. * 新增调试故障
  41. *
  42. * @param debugFault 调试故障
  43. * @return 结果
  44. */
  45. public int insertDebugFault(DebugFault debugFault) {
  46. debugFault.setCreateTime(DateUtils.getNowDate());
  47. return debugFaultMapper.insertDebugFault(debugFault);
  48. }
  49. /**
  50. * 修改调试故障
  51. *
  52. * @param debugFault 调试故障
  53. * @return 结果
  54. */
  55. public int updateDebugFault(DebugFault debugFault) {
  56. debugFault.setUpdateTime(DateUtils.getNowDate());
  57. return debugFaultMapper.updateDebugFault(debugFault);
  58. }
  59. /**
  60. * 批量删除调试故障
  61. *
  62. * @param refIds 需要删除的调试故障主键
  63. * @return 结果
  64. */
  65. public int deleteDebugFaultByRefIds(Long[] refIds) {
  66. return debugFaultMapper.deleteDebugFaultByRefIds(refIds);
  67. }
  68. /**
  69. * 删除调试故障信息
  70. *
  71. * @param refId 调试故障主键
  72. * @return 结果
  73. */
  74. public int deleteDebugFaultByRefId(Long refId) {
  75. return debugFaultMapper.deleteDebugFaultByRefId(refId);
  76. }
  77. // -------------------------------- tom add --------------------------------
  78. public DebugFault exist(Long simId, String faultId) {
  79. if (simId == null || simId == 0L) {
  80. return null;
  81. }
  82. if (StringUtils.isEmpty(faultId)) {
  83. return null;
  84. }
  85. DebugFault q = new DebugFault();
  86. q.setSimId(simId);
  87. q.setFaultId(faultId);
  88. List<DebugFault> list = selectDebugFaultList(q);
  89. if (!list.isEmpty()) {
  90. return list.get(0);
  91. }
  92. return null;
  93. }
  94. public int deleteAll() {
  95. DebugFault q = new DebugFault();
  96. List<DebugFault> list = selectDebugFaultList(q);
  97. Long[] refIds = new Long[list.size()];
  98. for (int i = 0; i < list.size(); i++) {
  99. refIds[i] = list.get(i).getRefId();
  100. }
  101. deleteDebugFaultByRefIds(refIds);
  102. return refIds.length;
  103. }
  104. public interface Flag {
  105. String YES = "1";
  106. String NO = "0";
  107. String UNKNOWN = "7";
  108. }
  109. }