20aa7277a04bbb66249fec9b4dd2e2b4662b553f.svn-base 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.BisInspStstnScoreDao;
  4. import cn.com.goldenwater.dcproj.model.BisInspStstnScore;
  5. import cn.com.goldenwater.dcproj.model.GwComFile;
  6. import cn.com.goldenwater.dcproj.param.BisInspStstnScoreParam;
  7. import cn.com.goldenwater.dcproj.service.BisInspStstnScoreService;
  8. import cn.com.goldenwater.dcproj.service.GwComFileService;
  9. import cn.com.goldenwater.id.util.UuidUtil;
  10. import cn.com.goldenwater.target.CheckException;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. import java.util.Date;
  16. import java.util.List;
  17. import java.util.Optional;
  18. /**
  19. * @author lhc
  20. * @date 2021-7-14
  21. */
  22. @Service
  23. @Transactional
  24. public class BisInspStstnScoreServiceImpl extends AbstractCrudService<BisInspStstnScore, BisInspStstnScoreParam> implements BisInspStstnScoreService {
  25. @Autowired
  26. private BisInspStstnScoreDao bisInspStstnScoreDao;
  27. @Autowired
  28. private GwComFileService gwComFileService;
  29. public BisInspStstnScoreServiceImpl(BisInspStstnScoreDao bisInspStstnScoreDao) {
  30. super(bisInspStstnScoreDao);
  31. this.bisInspStstnScoreDao = bisInspStstnScoreDao;
  32. }
  33. @Override
  34. public BisInspStstnScore get(String key) {
  35. BisInspStstnScore 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(BisInspStstnScore bisInspStstnScore) {
  44. if (StringUtils.isBlank(bisInspStstnScore.getCaseId())) {
  45. throw new CheckException("caseId为空");
  46. }
  47. if (StringUtils.isBlank(bisInspStstnScore.getScoreName())) {
  48. throw new CheckException("scoreName为空");
  49. }
  50. BisInspStstnScore score = getByCaseScore(bisInspStstnScore.getCaseId(), bisInspStstnScore.getScoreName());
  51. if (score != null) {
  52. return update(bisInspStstnScore);
  53. }
  54. String uuid = UuidUtil.uuid(); // 生成uuid
  55. bisInspStstnScore.setId(uuid);
  56. bisInspStstnScore.setIntm(new Date());
  57. bisInspStstnScore.setUptm(new Date());
  58. bisInspStstnScore.setDataStat("0");
  59. int ret = this.bisInspStstnScoreDao.insert(bisInspStstnScore);
  60. gwComFileService.updateBiz(bisInspStstnScore.getGwComFileList(), bisInspStstnScore.getId());
  61. return ret;
  62. }
  63. @Override
  64. public BisInspStstnScore getByCaseScore(String caseId, String scoreName) {
  65. BisInspStstnScore score = bisInspStstnScoreDao.getByCaseScore(caseId, scoreName);
  66. Optional.ofNullable(score).ifPresent(s -> {
  67. List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(s.getId());
  68. s.setGwComFileList(gwComFileList);
  69. });
  70. return score;
  71. }
  72. @Override
  73. public int update(BisInspStstnScore bisInspStstnScore) {
  74. BisInspStstnScore score = getByCaseScore(bisInspStstnScore.getCaseId(), bisInspStstnScore.getScoreName());
  75. if (score == null) {
  76. throw new CheckException("未找到指定修改数据");
  77. }
  78. bisInspStstnScore.setId(score.getId());
  79. bisInspStstnScore.setUptm(new Date());
  80. int ret = this.bisInspStstnScoreDao.update(bisInspStstnScore);
  81. gwComFileService.updateBiz(bisInspStstnScore.getGwComFileList(), bisInspStstnScore.getId());
  82. return ret;
  83. }
  84. @Override
  85. public int delete(String id) {
  86. return this.bisInspStstnScoreDao.delete(id);
  87. }
  88. }