bbae084b48cbeab87ebffddfdded8330f139ea41.svn-base 3.3 KB

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