116880650eb3a440e07c1732ba920ba4aaedbc52.svn-base 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. package cn.com.goldenwater.dcproj.service.impl.fjaccp;
  2. import cn.com.goldenwater.dcproj.dao.BisInspFjaccpDao;
  3. import cn.com.goldenwater.dcproj.dao.BisInspFjaccpTrgtDao;
  4. import cn.com.goldenwater.dcproj.model.BisInspFjaccp;
  5. import cn.com.goldenwater.dcproj.model.BisInspFjaccpTrgt;
  6. import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl;
  7. import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTrgt;
  8. import cn.com.goldenwater.dcproj.param.BisInspFjaccpTrgtParam;
  9. import cn.com.goldenwater.dcproj.service.BisInspFjaccpTrgtService;
  10. import cn.com.goldenwater.core.service.AbstractCrudService;
  11. import cn.com.goldenwater.target.CheckException;
  12. import com.github.pagehelper.PageHelper;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import org.springframework.transaction.annotation.Transactional;
  16. import cn.com.goldenwater.id.util.UuidUtil;
  17. import java.util.List;
  18. import java.util.Date;
  19. import java.util.Objects;
  20. /**
  21. * @author lhc
  22. * @date 2023-11-8
  23. */
  24. @Service
  25. @Transactional
  26. public class BisInspFjaccpTrgtServiceImpl extends AbstractCrudService<BisInspFjaccpTrgt, BisInspFjaccpTrgtParam> implements BisInspFjaccpTrgtService {
  27. @Autowired
  28. private BisInspFjaccpTrgtDao bisInspFjaccpTrgtDao;
  29. @Autowired
  30. private BisInspFjaccpDao bisInspFjaccpDao;
  31. public BisInspFjaccpTrgtServiceImpl(BisInspFjaccpTrgtDao bisInspFjaccpTrgtDao) {
  32. super(bisInspFjaccpTrgtDao);
  33. this.bisInspFjaccpTrgtDao = bisInspFjaccpTrgtDao;
  34. }
  35. @Override
  36. public int insert(BisInspFjaccpTrgt bisInspFjaccpTrgt) {
  37. String uuid = UuidUtil.uuid(); // 生成uuid
  38. bisInspFjaccpTrgt.setId(uuid);
  39. bisInspFjaccpTrgt.setIntm(new Date());
  40. bisInspFjaccpTrgt.setUptm(new Date());
  41. bisInspFjaccpTrgt.setDataStat("0");
  42. int insert = bisInspFjaccpTrgtDao.insert(bisInspFjaccpTrgt);
  43. scoreProcessing(bisInspFjaccpTrgt);
  44. return insert;
  45. }
  46. @Override
  47. public int update(BisInspFjaccpTrgt bisInspFjaccpTrgt) {
  48. bisInspFjaccpTrgt.setUptm(new Date());
  49. scoreProcessing(bisInspFjaccpTrgt);
  50. return this.bisInspFjaccpTrgtDao.update(bisInspFjaccpTrgt);
  51. }
  52. @Override
  53. public int delete(String id) {
  54. return this.bisInspFjaccpTrgtDao.delete(id);
  55. }
  56. /**
  57. * 分数处理
  58. *
  59. * @param obj 对象
  60. */
  61. private void scoreProcessing(BisInspFjaccpTrgt obj) {
  62. Double total1 = 0.0;//合计
  63. Double lac1 = 0.0;//缺项合计
  64. if(obj.getF111()==null){
  65. lac1 = lac1 + 2.0;
  66. }else{
  67. total1= total1+obj.getF111();
  68. }
  69. if(obj.getF112()==null){
  70. lac1 = lac1 + 3.0;
  71. }else{
  72. total1= total1+obj.getF112();
  73. }
  74. if(obj.getF113()==null){
  75. lac1 = lac1 + 4.0;
  76. }else{
  77. total1= total1+obj.getF113();
  78. }
  79. if(obj.getF114()==null){
  80. lac1 = lac1 + 5.0;
  81. }else{
  82. total1= total1+obj.getF114();
  83. }
  84. if(obj.getF115()==null){
  85. lac1 = lac1 + 6.0;
  86. }else{
  87. total1= total1+obj.getF115();
  88. }
  89. if(obj.getF116()==null){
  90. lac1 = lac1 + 10.0;
  91. }else{
  92. total1= total1+obj.getF116();
  93. }
  94. if(obj.getF121()==null){
  95. lac1 = lac1 + 4.0;
  96. }else{
  97. total1= total1+obj.getF121();
  98. }
  99. if(obj.getF122()==null){
  100. lac1 = lac1 + 5.0;
  101. }else{
  102. total1= total1+obj.getF122();
  103. }
  104. if(obj.getF123()==null){
  105. lac1 = lac1 + 6.0;
  106. }else{
  107. total1= total1+obj.getF123();
  108. }
  109. if(obj.getF124()==null){
  110. lac1 = lac1 + 9.0;
  111. }else{
  112. total1= total1+obj.getF124();
  113. }
  114. if(obj.getF125()==null){
  115. lac1 = lac1 + 4.0;
  116. }else{
  117. total1= total1+obj.getF125();
  118. }
  119. if(obj.getF131()==null){
  120. lac1 = lac1 + 8.0;
  121. }else{
  122. total1= total1+obj.getF131();
  123. }
  124. if(obj.getF132()==null){
  125. lac1 = lac1 + 6.0;
  126. }else{
  127. total1= total1+obj.getF132();
  128. }
  129. if(obj.getF141()==null){
  130. lac1 = lac1 + 2.0;
  131. }else{
  132. total1= total1+obj.getF141();
  133. }
  134. if(obj.getF142()==null){
  135. lac1 = lac1 + 15.0;
  136. }else{
  137. total1= total1+obj.getF142();
  138. }
  139. if(obj.getF143()==null){
  140. lac1 = lac1 + 8.0;
  141. }else{
  142. total1= total1+obj.getF143();
  143. }
  144. if(obj.getF144()==null){
  145. lac1 = lac1 + 18.0;
  146. }else{
  147. total1= total1+obj.getF144();
  148. }
  149. if(obj.getF145()==null){
  150. lac1 = lac1 + 7.0;
  151. }else{
  152. total1= total1+obj.getF145();
  153. }
  154. if(obj.getF146()==null){
  155. lac1 = lac1 + 8.0;
  156. }else{
  157. total1= total1+obj.getF146();
  158. }
  159. if(obj.getF151()==null){
  160. lac1 = lac1 + 5.0;
  161. }else{
  162. total1= total1+obj.getF151();
  163. }
  164. if(obj.getF152()==null){
  165. lac1 = lac1 + 5.0;
  166. }else{
  167. total1= total1+obj.getF152();
  168. }
  169. if(obj.getF161()==null){
  170. lac1 = lac1 + 10.0;
  171. }else{
  172. total1= total1+obj.getF161();
  173. }
  174. BisInspFjaccp rgstr = bisInspFjaccpDao.get(obj.getRgstrId());
  175. if (rgstr == null) {
  176. throw new CheckException("未找到此登记表");
  177. }
  178. //算总分和缺项、评分率
  179. Double tatl = judge(total1)+judge(rgstr.getSystemTatl())+judge(rgstr.getTvetTatl())+judge(rgstr.getImgrTatl())
  180. + judge(rgstr.getSafdlTatl())+judge(rgstr.getEmTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl());
  181. Double lacSoc = judge(lac1)+judge(rgstr.getSystemLac())+judge(rgstr.getTvetLac())+judge(rgstr.getImgrLac())
  182. + judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac());
  183. BisInspFjaccp bisInspFj = new BisInspFjaccp();
  184. bisInspFj.setId(rgstr.getId());
  185. bisInspFj.setTrgtTatl(total1);
  186. bisInspFj.setTrgtLac(lac1);
  187. bisInspFj.setTrgtStat(obj.getState());
  188. //设置总分和评定得分
  189. if(tatl!=null || tatl != 0){
  190. bisInspFj.setTatl(Math.round(tatl*10.0)/10.0);
  191. Double soc = 1000-lacSoc;
  192. if(soc!=null && soc != 0){
  193. Double ratSoc = tatl/(1000-lacSoc)*100;
  194. bisInspFj.setRatSoc(Math.round(ratSoc*10.0)/10.0);
  195. }
  196. }
  197. bisInspFj.setState("1");
  198. bisInspFj.setUptm(new Date());
  199. bisInspFjaccpDao.update(bisInspFj);
  200. }
  201. private Double judge(Double value) {
  202. if (Objects.isNull(value)) {
  203. return 0.0;
  204. }
  205. return value;
  206. }
  207. }