32362fb71cf98bfc01c51692e05d595970523b01.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package cn.com.goldenwater.dcproj.service.impl.fjpjlgl;
  2. import cn.com.goldenwater.dcproj.dao.BisInspFjpjlglDao;
  3. import cn.com.goldenwater.dcproj.dao.BisInspFjpjlglTvetDao;
  4. import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl;
  5. import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTrgt;
  6. import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTvet;
  7. import cn.com.goldenwater.dcproj.param.BisInspFjpjlglTvetParam;
  8. import cn.com.goldenwater.dcproj.service.BisInspFjpjlglTvetService;
  9. import cn.com.goldenwater.core.service.AbstractCrudService;
  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.Objects;
  19. /**
  20. * @author lhc
  21. * @date 2023-11-7
  22. */
  23. @Service
  24. @Transactional
  25. public class BisInspFjpjlglTvetServiceImpl extends AbstractCrudService<BisInspFjpjlglTvet, BisInspFjpjlglTvetParam> implements BisInspFjpjlglTvetService {
  26. @Autowired
  27. private BisInspFjpjlglTvetDao bisInspFjpjlglTvetDao;
  28. @Autowired
  29. private BisInspFjpjlglDao bisInspFjpjlglDao;
  30. public BisInspFjpjlglTvetServiceImpl(BisInspFjpjlglTvetDao bisInspFjpjlglTvetDao) {
  31. super(bisInspFjpjlglTvetDao);
  32. this.bisInspFjpjlglTvetDao = bisInspFjpjlglTvetDao;
  33. }
  34. @Override
  35. public int insert(BisInspFjpjlglTvet bisInspFjpjlglTvet) {
  36. String uuid = UuidUtil.uuid(); // 生成uuid
  37. bisInspFjpjlglTvet.setId(uuid);
  38. bisInspFjpjlglTvet.setIntm(new Date());
  39. bisInspFjpjlglTvet.setUptm(new Date());
  40. bisInspFjpjlglTvet.setDataStat("0");
  41. int insert = bisInspFjpjlglTvetDao.insert(bisInspFjpjlglTvet);
  42. scoreProcessing(bisInspFjpjlglTvet);
  43. return insert;
  44. }
  45. @Override
  46. public int update(BisInspFjpjlglTvet bisInspFjpjlglTvet) {
  47. bisInspFjpjlglTvet.setUptm(new Date());
  48. scoreProcessing(bisInspFjpjlglTvet);
  49. return this.bisInspFjpjlglTvetDao.update(bisInspFjpjlglTvet);
  50. }
  51. @Override
  52. public int delete(String id) {
  53. return this.bisInspFjpjlglTvetDao.delete(id);
  54. }
  55. /**
  56. * 分数处理
  57. *
  58. * @param obj 对象
  59. */
  60. private void scoreProcessing(BisInspFjpjlglTvet obj) {
  61. Double total1 = 0.0;//合计
  62. Double lac1 = 0.0;//缺项合计
  63. if(obj.getF311()==null){
  64. lac1 = lac1 + 5.0;
  65. }else{
  66. total1= total1+obj.getF311();
  67. }
  68. if(obj.getF312()==null){
  69. lac1 = lac1 + 5.0;
  70. }else{
  71. total1= total1+obj.getF312();
  72. }
  73. if(obj.getF321()==null){
  74. lac1 = lac1 + 15.0;
  75. }else{
  76. total1= total1+obj.getF321();
  77. }
  78. if(obj.getF322()==null){
  79. lac1 = lac1 + 8.0;
  80. }else{
  81. total1= total1+obj.getF322();
  82. }
  83. if(obj.getF323()==null){
  84. lac1 = lac1 + 10.0;
  85. }else{
  86. total1= total1+obj.getF323();
  87. }
  88. if(obj.getF324()==null){
  89. lac1 = lac1 + 7.0;
  90. }else{
  91. total1= total1+obj.getF324();
  92. }
  93. if(obj.getF325()==null){
  94. lac1 = lac1 + 5.0;
  95. }else{
  96. total1= total1+obj.getF325();
  97. }
  98. if(obj.getF326()==null){
  99. lac1 = lac1 + 5.0;
  100. }else{
  101. total1= total1+obj.getF326();
  102. }
  103. BisInspFjpjlgl rgstr = bisInspFjpjlglDao.get(obj.getRgstrId());
  104. if (rgstr == null) {
  105. throw new CheckException("未找到此登记表");
  106. }
  107. //算总分和缺项、评分率
  108. Double tatl = judge(total1)+
  109. judge(rgstr.getSystemTatl())+judge(rgstr.getTrgtTatl())+judge(rgstr.getImgrTatl())
  110. + judge(rgstr.getSafdlTatl())+judge(rgstr.getEmTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl());
  111. Double lacSoc = judge(lac1)+
  112. judge(rgstr.getSystemLac())+judge(rgstr.getTrgtLac())+judge(rgstr.getImgrLac())
  113. + judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac());
  114. BisInspFjpjlgl bisInspFjpjlgl = new BisInspFjpjlgl();
  115. bisInspFjpjlgl.setId(rgstr.getId());
  116. bisInspFjpjlgl.setTvetTatl(total1);
  117. bisInspFjpjlgl.setTvetLac(lac1);
  118. bisInspFjpjlgl.setTvetStat(obj.getState());
  119. //设置总分和评定得分
  120. if(tatl!=null || tatl != 0){
  121. bisInspFjpjlgl.setTatl(Math.round(tatl*10.0)/10.0);
  122. Double soc = 1000-lacSoc;
  123. if(soc!=null && soc != 0){
  124. Double ratSoc = tatl/(1000-lacSoc)*100;
  125. bisInspFjpjlgl.setRatSoc(Math.round(ratSoc*10.0)/10.0);
  126. }
  127. }
  128. bisInspFjpjlgl.setState("1");
  129. bisInspFjpjlgl.setUptm(new Date());
  130. bisInspFjpjlglDao.update(bisInspFjpjlgl);
  131. }
  132. private Double judge(Double value) {
  133. if (Objects.isNull(value)) {
  134. return 0.0;
  135. }
  136. return value;
  137. }
  138. }