D10002Service.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package com.miniframe.bisiness.system;
  2. import java.util.Map;
  3. import com.miniframe.core.ExecProcessFlow;
  4. import com.miniframe.core.exception.BusinessException;
  5. import com.miniframe.core.ext.UtilTools;
  6. import com.miniframe.generate.business.system.model.D10002BaseModel;
  7. import com.miniframe.model.system.DNode;
  8. import com.miniframe.model.system.DPipe;
  9. import com.miniframe.model.system.DPipeSQLBuilder;
  10. import com.miniframe.model.system.dao.DNodeMapper;
  11. import com.miniframe.model.system.dao.DPipeMapper;
  12. /**
  13. * 基础系统,“管道数据添加修改”逻辑处理(重新生成不覆盖)。
  14. */
  15. public class D10002Service extends D10002BaseModel implements ExecProcessFlow {
  16. private static final long serialVersionUID = -7051358269847459502L;
  17. /**
  18. * 基础系统,“管道数据添加修改”业务核心处理
  19. */
  20. public void transExecute() throws Exception {
  21. DPipeMapper dPipeDao = UtilTools.getBean(DPipeMapper.class);
  22. Integer pid = this.getA_d10002().getPid();
  23. String name =this.getA_d10002().getName();
  24. Integer snId = this.getA_d10002().getSnId();
  25. Integer enId =this.getA_d10002().getEnId();
  26. String roughCoe =this.getA_d10002().getRoughCoe();
  27. String sectionType =this.getA_d10002().getSectionType();
  28. String sectionPara1 =this.getA_d10002().getSectionPara1();
  29. String sectionPara2 =this.getA_d10002().getSectionPara2();
  30. String sectionPara3 =this.getA_d10002().getSectionPara3();
  31. String sectionPara4 =this.getA_d10002().getSectionPara4();
  32. String sectionPara5 =this.getA_d10002().getSectionPara5();
  33. if(pid ==null || pid<=0){//添加
  34. pdSnIdEnId(dPipeDao,snId,enId);
  35. savePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5);
  36. }else{//修改
  37. DPipe pipe =dPipeDao.selectByPrimaryKey(pid);
  38. if(pipe==null){
  39. throw new BusinessException("EB3100002");
  40. }
  41. updatePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5, pipe);
  42. }
  43. }
  44. private void updatePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType, String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5, DPipe pipe) {
  45. pipe.setName(name);
  46. pipe.setSnid(snId);
  47. pipe.setEnid(enId);
  48. pipe.setRoughCoe(Float.valueOf(roughCoe));
  49. pipe.setSectionType(sectionType);
  50. pipe.setSectionPara1(Float.valueOf(sectionPara1));
  51. pipe.setSectionPara2(Float.valueOf(sectionPara2));
  52. pipe.setSectionPara3(Float.valueOf(sectionPara3));
  53. pipe.setSectionPara4(Float.valueOf(sectionPara4));
  54. pipe.setSectionPara5(Float.valueOf(sectionPara5));
  55. dPipeDao.updateByPrimaryKey(pipe);
  56. }
  57. public void pdSnIdEnIdExPid(DPipeMapper dPipeDao,Integer snId,Integer enId,Integer pid) throws BusinessException {
  58. DPipeSQLBuilder sb =new DPipeSQLBuilder();
  59. DPipeSQLBuilder.Criteria sc = sb.createCriteria();
  60. sc.andSnidEqualTo(snId);
  61. sc.andEnidEqualTo(enId);
  62. sc.andIdNotEqualTo(pid);
  63. DPipe pip = dPipeDao.selectOneByExample(sb);
  64. if(pip!=null){
  65. throw new BusinessException("EB3100001");
  66. }
  67. }
  68. private void savePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType, String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5) {
  69. DPipe pipe =new DPipe();
  70. pipe.setName(name);
  71. pipe.setSnid(snId);
  72. pipe.setEnid(enId);
  73. pipe.setRoughCoe(Float.valueOf(roughCoe));
  74. pipe.setSectionType(sectionType);
  75. pipe.setSectionPara1(Float.valueOf(sectionPara1!=null?sectionPara1:"0"));
  76. pipe.setSectionPara2(Float.valueOf(sectionPara2!=null?sectionPara2:"0"));
  77. pipe.setSectionPara3(Float.valueOf(sectionPara3!=null?sectionPara3:"0"));
  78. pipe.setSectionPara4(Float.valueOf(sectionPara4!=null?sectionPara4:"0"));
  79. pipe.setSectionPara5(Float.valueOf(sectionPara5!=null?sectionPara5:"0"));
  80. dPipeDao.insertSelective(pipe);
  81. }
  82. public void pdSnIdEnId(DPipeMapper dPipeDao,Integer snId,Integer enId) throws BusinessException {
  83. DPipeSQLBuilder sb =new DPipeSQLBuilder();
  84. DPipeSQLBuilder.Criteria sc = sb.createCriteria();
  85. sc.andSnidEqualTo(snId);
  86. sc.andEnidEqualTo(enId);
  87. DPipe pip = dPipeDao.selectOneByExample(sb);
  88. if(pip!=null){
  89. throw new BusinessException("EB3100001");
  90. }
  91. }
  92. /**
  93. * 基础系统,“管道数据添加修改”业务前处理
  94. */
  95. public void preTransFlow() throws Exception {
  96. this.validater();
  97. }
  98. /**
  99. * 基础系统,“管道数据添加修改”业务后处理
  100. */
  101. public void afterTransFlow() throws Exception {
  102. }
  103. /**
  104. * 基础系统,“管道数据添加修改”逻辑入口处理方法
  105. */
  106. @SuppressWarnings("rawtypes")
  107. @Override
  108. public Map execute(Map vars) throws Exception {
  109. this.setTransMap(vars);
  110. preTransFlow();// 执行业务开始的规则检查和校验
  111. transExecute();// 执行核心业务段
  112. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  113. return this.getTransMap();
  114. }
  115. }