6bf5e7a954c8fd59241e4329ef005762d8a4bcda.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.dcproj.dao.BisInspQaScoreSdDao;
  3. import cn.com.goldenwater.dcproj.model.BisInspQaScore;
  4. import cn.com.goldenwater.dcproj.model.BisInspQaScoreSd;
  5. import cn.com.goldenwater.dcproj.param.BisInspQaScoreSdParam;
  6. import cn.com.goldenwater.dcproj.service.BisInspQaScoreSdService;
  7. import cn.com.goldenwater.core.service.AbstractCrudService;
  8. import cn.com.goldenwater.dcproj.service.BisInspQaSdService;
  9. import cn.com.goldenwater.target.CheckException;
  10. import com.github.pagehelper.PageHelper;
  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.*;
  16. import java.util.concurrent.atomic.LongAdder;
  17. /**
  18. * @author lhc
  19. * @date 2024-4-7
  20. */
  21. @Service
  22. @Transactional(rollbackFor = Exception.class)
  23. public class BisInspQaScoreSdServiceImpl extends AbstractCrudService<BisInspQaScoreSd, BisInspQaScoreSdParam> implements BisInspQaScoreSdService {
  24. @Autowired
  25. private BisInspQaScoreSdDao bisInspQaScoreSdDao;
  26. @Autowired
  27. private BisInspQaSdService bisInspQaSdService;
  28. public BisInspQaScoreSdServiceImpl(BisInspQaScoreSdDao bisInspQaScoreSdDao) {
  29. super(bisInspQaScoreSdDao);
  30. this.bisInspQaScoreSdDao = bisInspQaScoreSdDao;
  31. }
  32. @Override
  33. public int insert(BisInspQaScoreSd bisInspQaScoreSd) {
  34. String uuid = UuidUtil.uuid(); // 生成uuid
  35. bisInspQaScoreSd.setId(uuid);
  36. bisInspQaScoreSd.setIntm(new Date());
  37. bisInspQaScoreSd.setUptm(new Date());
  38. bisInspQaScoreSd.setDataStat("0");
  39. return this.bisInspQaScoreSdDao.insert(bisInspQaScoreSd);
  40. }
  41. @Override
  42. public int update(BisInspQaScoreSd bisInspQaScoreSd) {
  43. BisInspQaScoreSd score = get(bisInspQaScoreSd.getRgstrId());
  44. if (score == null) {
  45. throw new CheckException("未找到此登记表下的子表");
  46. }
  47. bisInspQaScoreSd.setId(score.getId());
  48. bisInspQaScoreSd.setUptm(new Date());
  49. //分数处理
  50. scoreProcessing(bisInspQaScoreSd);
  51. return this.bisInspQaScoreSdDao.update(bisInspQaScoreSd);
  52. }
  53. @Override
  54. public int delete(String id) {
  55. return this.bisInspQaScoreSdDao.delete(id);
  56. }
  57. /**
  58. * 分数处理
  59. *
  60. * @param obj 对象
  61. */
  62. private void scoreProcessing(BisInspQaScoreSd obj) {
  63. //扣分合计
  64. LongAdder empSub = new LongAdder();
  65. empSub.add(judge(obj.getQaMgr()));
  66. empSub.add(judge(obj.getQaDst()));
  67. empSub.add(judge(obj.getQaNewEta()));
  68. empSub.add(judge(obj.getQaBuld()));
  69. empSub.add(judge(obj.getQaZrr()));
  70. empSub.add(judge(obj.getQaGzyd()));
  71. empSub.add(judge(obj.getQaZgls()));
  72. empSub.add(judge(obj.getQaJdsq()));
  73. empSub.add(judge(obj.getQaGzjh()));
  74. empSub.add(judge(obj.getQaXmhf()));
  75. empSub.add(judge(obj.getQaPdbz()));
  76. empSub.add(judge(obj.getQaZzqk()));
  77. empSub.add(judge(obj.getQaJlqk()));
  78. empSub.add(judge(obj.getQaYxqk()));
  79. empSub.add(judge(obj.getQaJdjc()));
  80. empSub.add(judge(obj.getQaZljl()));
  81. empSub.add(judge(obj.getQaWtcl()));
  82. empSub.add(judge(obj.getQaZszrz()));
  83. empSub.add(judge(obj.getQaZdbg()));
  84. empSub.add(judge(obj.getQaJdda()));
  85. empSub.add(judge(obj.getQaJbts()));
  86. empSub.add(judge(obj.getQaFwxw()));
  87. //加分合计
  88. LongAdder empAdd = new LongAdder();
  89. empAdd.add(judge(obj.getQaSpts()));
  90. empAdd.add(judge(obj.getQaGlxxh()));
  91. //总分值
  92. long totalScore = 100L;
  93. long subTotal = empSub.longValue();
  94. long addTotal = empAdd.longValue();
  95. //得分=总分值-减分项+加分项
  96. long total = totalScore - subTotal + addTotal;
  97. obj.setSubTotal(subTotal);
  98. obj.setAddTotal(addTotal);
  99. obj.setTotal(total);
  100. //赋值
  101. updateRgstrState(obj);
  102. }
  103. private long judge(Long value) {
  104. if (Objects.isNull(value)) {
  105. return 0L;
  106. }
  107. return value;
  108. }
  109. private void updateRgstrState(BisInspQaScoreSd bisInspQaScoreSd) {
  110. Map<String,Object> map = new HashMap<>(4);
  111. map.put("rgstrId",bisInspQaScoreSd.getRgstrId());
  112. map.put("param","qa");
  113. map.put("total",bisInspQaScoreSd.getTotal());
  114. bisInspQaSdService.updateState(map);
  115. }
  116. }