3c1a8fe19daeba6c9fd2b66be16976768c615151.svn-base 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.dcproj.dao.BisInspQaScore1SdDao;
  3. import cn.com.goldenwater.dcproj.model.BisInspQaScore1Sd;
  4. import cn.com.goldenwater.dcproj.model.GwComFile;
  5. import cn.com.goldenwater.dcproj.param.BisInspQaScore1SdParam;
  6. import cn.com.goldenwater.dcproj.service.BisInspQaScore1SdService;
  7. import cn.com.goldenwater.core.service.AbstractCrudService;
  8. import cn.com.goldenwater.dcproj.service.GwComFileService;
  9. import cn.com.goldenwater.dcproj.utils.StringUtils;
  10. import cn.com.goldenwater.target.CheckException;
  11. import com.github.pagehelper.PageHelper;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import java.util.List;
  17. import java.util.Date;
  18. import java.util.Optional;
  19. /**
  20. * @author lhc
  21. * @date 2024-4-7
  22. */
  23. @Service
  24. @Transactional
  25. public class BisInspQaScore1SdServiceImpl extends AbstractCrudService<BisInspQaScore1Sd, BisInspQaScore1SdParam> implements BisInspQaScore1SdService {
  26. @Autowired
  27. private BisInspQaScore1SdDao bisInspQaScore1SdDao;
  28. @Autowired
  29. private GwComFileService gwComFileService;
  30. public BisInspQaScore1SdServiceImpl(BisInspQaScore1SdDao bisInspQaScore1SdDao) {
  31. super(bisInspQaScore1SdDao);
  32. this.bisInspQaScore1SdDao = bisInspQaScore1SdDao;
  33. }
  34. @Override
  35. public BisInspQaScore1Sd get(String key) {
  36. BisInspQaScore1Sd score = super.get(key);
  37. Optional.ofNullable(score).ifPresent(s -> {
  38. List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(s.getId());
  39. s.setGwComFileList(gwComFileList);
  40. });
  41. return score;
  42. }
  43. @Override
  44. public int insert(BisInspQaScore1Sd bisInspQaScore1Sd) {
  45. if (StringUtils.isBlank(bisInspQaScore1Sd.getCaseId())) {
  46. throw new CheckException("caseId为空");
  47. }
  48. if (StringUtils.isBlank(bisInspQaScore1Sd.getScoreName())) {
  49. throw new CheckException("scoreName为空");
  50. }
  51. BisInspQaScore1Sd score = getByCaseScore(bisInspQaScore1Sd.getCaseId(), bisInspQaScore1Sd.getScoreName());
  52. if (score != null) {
  53. return update(bisInspQaScore1Sd);
  54. }
  55. // 生成uuid
  56. String uuid = UuidUtil.uuid();
  57. bisInspQaScore1Sd.setId(uuid);
  58. bisInspQaScore1Sd.setIntm(new Date());
  59. bisInspQaScore1Sd.setUptm(new Date());
  60. bisInspQaScore1Sd.setDataStat("0");
  61. int ret = this.bisInspQaScore1SdDao.insert(bisInspQaScore1Sd);
  62. gwComFileService.updateBiz(bisInspQaScore1Sd.getGwComFileList(), bisInspQaScore1Sd.getId());
  63. return ret;
  64. }
  65. @Override
  66. public int update(BisInspQaScore1Sd bisInspQaScore1Sd) {
  67. bisInspQaScore1Sd.setUptm(new Date());
  68. return this.bisInspQaScore1SdDao.update(bisInspQaScore1Sd);
  69. }
  70. @Override
  71. public int delete(String id) {
  72. return this.bisInspQaScore1SdDao.delete(id);
  73. }
  74. @Override
  75. public BisInspQaScore1Sd getByCaseScore(String caseId, String scoreName) {
  76. BisInspQaScore1Sd score = bisInspQaScore1SdDao.getByCaseScore(caseId, scoreName);
  77. Optional.ofNullable(score).ifPresent(s -> {
  78. List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(s.getId());
  79. s.setGwComFileList(gwComFileList);
  80. });
  81. return score;
  82. }
  83. }