D10018Service.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package com.miniframe.bisiness.system;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.miniframe.core.ExecProcessFlow;
  6. import com.miniframe.core.exception.BusinessException;
  7. import com.miniframe.core.ext.UtilTools;
  8. import com.miniframe.generate.business.system.model.D10018BaseModel;
  9. import com.miniframe.generate.comm.system.D_D10018_COCODES_RECODE;
  10. import com.miniframe.generate.comm.system.D_D10018_CODES_RECODE;
  11. import com.miniframe.generate.comm.system.D_D10018_VALS_RECODE;
  12. import com.miniframe.model.system.*;
  13. import com.miniframe.model.system.dao.DAccidentMapper;
  14. import com.miniframe.model.system.dao.DChecknodeValMapper;
  15. import com.miniframe.model.system.dao.DChecknodeValcodeMapper;
  16. import io.netty.util.internal.StringUtil;
  17. /**
  18. * 基础系统,“监测点结果获取”逻辑处理(重新生成不覆盖)。
  19. */
  20. public class D10018Service extends D10018BaseModel implements ExecProcessFlow {
  21. private static final long serialVersionUID = -7051358269847459502L;
  22. /**
  23. * 基础系统,“监测点结果获取”业务核心处理
  24. */
  25. public void transExecute() throws Exception {
  26. Integer aid= getA_d10018().getAid();
  27. Integer step =getA_d10018().getStep();
  28. DAccidentMapper accidentDao = UtilTools.getBean(DAccidentMapper.class);
  29. DAccident accident= accidentDao.selectByPrimaryKey(aid);
  30. List<D_D10018_CODES_RECODE> codes =new ArrayList<>();
  31. findValCode(aid, accident, codes);
  32. List<D_D10018_VALS_RECODE> vals =new ArrayList<>();
  33. findVal(aid, step, accident, vals);
  34. this.getD_d10018().setCodes(codes);
  35. this.getD_d10018().setVals(vals);
  36. }
  37. private void findVal(Integer aid, Integer step, DAccident accident, List<D_D10018_VALS_RECODE> vals) {
  38. DChecknodeValMapper valMapper =UtilTools.getBean(DChecknodeValMapper.class);
  39. DChecknodeValSQLBuilder sb = new DChecknodeValSQLBuilder();
  40. DChecknodeValSQLBuilder.Criteria sc =sb.createCriteria();
  41. sc.andAidEqualTo(aid);
  42. sc.andJidEqualTo(accident.getJid());
  43. sc.andStepEqualTo(step);
  44. sb.setOrderByClause("id ASC");
  45. List<DChecknodeVal> nVals = valMapper.selectByExample(sb);
  46. for (DChecknodeVal nval:nVals) {
  47. D_D10018_VALS_RECODE val =new D_D10018_VALS_RECODE();
  48. val.setChname(nval.getChname());
  49. val.setV1(nval.getV1());
  50. val.setV2(nval.getV2());
  51. val.setV3(nval.getV3());
  52. val.setV4(nval.getV4());
  53. val.setV5(nval.getV5());
  54. val.setV6(nval.getV6());
  55. vals.add(val);
  56. }
  57. }
  58. private void findValCode(Integer aid, DAccident accident, List<D_D10018_CODES_RECODE> codes) throws BusinessException {
  59. DChecknodeValcodeMapper valcodeMapper =UtilTools.getBean(DChecknodeValcodeMapper.class);
  60. DChecknodeValcodeSQLBuilder codesb =new DChecknodeValcodeSQLBuilder();
  61. DChecknodeValcodeSQLBuilder.Criteria codesc = codesb.createCriteria();
  62. codesc.andAidEqualTo(aid);
  63. codesc.andJidEqualTo(accident.getJid());
  64. List<DChecknodeValcode> valcodes = valcodeMapper.selectByExample(codesb );
  65. if(valcodes.isEmpty()){
  66. throw new BusinessException("EB3100026");
  67. }
  68. DChecknodeValcode valcode =valcodes.get(0);
  69. setCodes(valcode, codes);
  70. }
  71. private void setCodes(DChecknodeValcode valcode, List<D_D10018_CODES_RECODE> codes) {
  72. if(!StringUtil.isNullOrEmpty(valcode.getValCode1()))
  73. {
  74. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  75. code.setCode(valcode.getValCode1());
  76. codes.add(code);
  77. }
  78. if(!StringUtil.isNullOrEmpty(valcode.getValCode2()))
  79. {
  80. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  81. code.setCode(valcode.getValCode2());
  82. codes.add(code);
  83. }
  84. if(!StringUtil.isNullOrEmpty(valcode.getValCode3()))
  85. {
  86. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  87. code.setCode(valcode.getValCode3());
  88. codes.add(code);
  89. }
  90. if(!StringUtil.isNullOrEmpty(valcode.getValCode4()))
  91. {
  92. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  93. code.setCode(valcode.getValCode4());
  94. codes.add(code);
  95. }
  96. if(!StringUtil.isNullOrEmpty(valcode.getValCode5()))
  97. {
  98. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  99. code.setCode(valcode.getValCode5());
  100. codes.add(code);
  101. }
  102. if(!StringUtil.isNullOrEmpty(valcode.getValCode6()))
  103. {
  104. D_D10018_CODES_RECODE code =new D_D10018_CODES_RECODE();
  105. code.setCode(valcode.getValCode6());
  106. codes.add(code);
  107. }
  108. }
  109. /**
  110. * 基础系统,“监测点结果获取”业务前处理
  111. */
  112. public void preTransFlow() throws Exception {
  113. this.validater();
  114. }
  115. /**
  116. * 基础系统,“监测点结果获取”业务后处理
  117. */
  118. public void afterTransFlow() throws Exception {
  119. }
  120. /**
  121. * 基础系统,“监测点结果获取”逻辑入口处理方法
  122. */
  123. @SuppressWarnings("rawtypes")
  124. @Override
  125. public Map execute(Map vars) throws Exception {
  126. this.setTransMap(vars);
  127. preTransFlow();// 执行业务开始的规则检查和校验
  128. transExecute();// 执行核心业务段
  129. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  130. return this.getTransMap();
  131. }
  132. }