D10002Service.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.SysFile;
  11. import com.miniframe.model.system.dao.DNodeMapper;
  12. import com.miniframe.model.system.dao.DPipeMapper;
  13. import com.miniframe.model.system.dao.SysFileMapper;
  14. import tk.mybatis.mapper.util.StringUtil;
  15. /**
  16. * 基础系统,“管道数据添加修改”逻辑处理(重新生成不覆盖)。
  17. */
  18. public class D10002Service extends D10002BaseModel implements ExecProcessFlow {
  19. private static final long serialVersionUID = -7051358269847459502L;
  20. /**
  21. * 基础系统,“管道数据添加修改”业务核心处理
  22. */
  23. public void transExecute() throws Exception {
  24. DPipeMapper dPipeDao = UtilTools.getBean(DPipeMapper.class);
  25. Integer pid = this.getA_d10002().getPid();
  26. String name =this.getA_d10002().getName();
  27. Integer snId = this.getA_d10002().getSnId();
  28. Integer enId =this.getA_d10002().getEnId();
  29. String roughCoe =this.getA_d10002().getRoughCoe();
  30. String sectionType =this.getA_d10002().getSectionType();
  31. String sectionPara1 =this.getA_d10002().getSectionPara1();
  32. String sectionPara2 =this.getA_d10002().getSectionPara2();
  33. String sectionPara3 =this.getA_d10002().getSectionPara3();
  34. String sectionPara4 =this.getA_d10002().getSectionPara4();
  35. String sectionPara5 =this.getA_d10002().getSectionPara5();
  36. String roughCoeName=this.getA_d10002().getRoughCoeName();
  37. String code =this.getA_d10002().getCode();
  38. String gfid = this.getA_d10002().getGfid();
  39. String bfid = this.getA_d10002().getBfid();
  40. SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class);
  41. SysFile gf = sysFileMapper.selectByPrimaryKey(gfid);
  42. // if (gf == null) {
  43. //// throw new BusinessException("EB3100020");
  44. // }
  45. SysFile bf = sysFileMapper.selectByPrimaryKey(bfid);
  46. // if (bf == null) {
  47. //// throw new BusinessException("EB3100021");
  48. // }
  49. DNodeMapper nodeMapper =UtilTools.getBean(DNodeMapper.class);
  50. DNode sNode = nodeMapper.selectByPrimaryKey(snId);
  51. DNode eNode = nodeMapper.selectByPrimaryKey(enId);
  52. if(sNode==null || eNode==null){
  53. throw new BusinessException("EB3000001");
  54. }
  55. if(pid ==null || pid<=0){//添加
  56. pdSnIdEnId(dPipeDao,snId,enId);
  57. savePipe(dPipeDao, name, snId, enId, roughCoe,
  58. sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5,code,roughCoeName,gf,bf);
  59. }else{//修改
  60. DPipe pipe =dPipeDao.selectByPrimaryKey(pid);
  61. pdSnIdEnIdNotPid(dPipeDao,snId,enId,pid);
  62. if(pipe==null){
  63. throw new BusinessException("EB3100002");
  64. }
  65. updatePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4,
  66. sectionPara5,roughCoeName, pipe,code,gf,bf);
  67. }
  68. }
  69. public void pdSnIdEnIdNotPid(DPipeMapper dPipeDao,Integer snId,Integer enId, Integer pid) throws BusinessException {
  70. DPipeSQLBuilder sb =new DPipeSQLBuilder();
  71. DPipeSQLBuilder.Criteria sc = sb.createCriteria();
  72. sc.andSnidEqualTo(snId);
  73. sc.andEnidEqualTo(enId);
  74. sc.andIdNotEqualTo(pid);
  75. DPipe pip = dPipeDao.selectOneByExample(sb);
  76. if(pip!=null){
  77. throw new BusinessException("EB3100001");
  78. }
  79. }
  80. private void updatePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe,
  81. String sectionType, String sectionPara1, String sectionPara2, String sectionPara3,
  82. String sectionPara4, String sectionPara5,String roughCoeName, DPipe pipe,String code,SysFile gf,SysFile bf) {
  83. pipe.setName(name);
  84. pipe.setSnid(snId);
  85. pipe.setEnid(enId);
  86. pipe.setRoughCoe(Float.valueOf(roughCoe));
  87. pipe.setSectionType(sectionType);
  88. pipe.setSectionPara1(Float.valueOf(!StringUtil.isEmpty(sectionPara1)?sectionPara1:"0"));
  89. pipe.setSectionPara2(Float.valueOf(!StringUtil.isEmpty(sectionPara2)?sectionPara2:"0"));
  90. pipe.setSectionPara3(Float.valueOf(!StringUtil.isEmpty(sectionPara3)?sectionPara3:"0"));
  91. pipe.setSectionPara4(Float.valueOf(!StringUtil.isEmpty(sectionPara4)?sectionPara4:"0"));
  92. pipe.setSectionPara5(Float.valueOf(!StringUtil.isEmpty(sectionPara5)?sectionPara5:"0"));
  93. pipe.setCode(code);
  94. pipe.setRoughCoeName(roughCoeName);
  95. if(gf!=null){
  96. pipe.setGfid(gf.getId());
  97. pipe.setGfname(gf.getFilename());
  98. }
  99. if(bf!=null){
  100. pipe.setBfid(bf.getId());
  101. pipe.setBfname(bf.getFilename());
  102. }
  103. dPipeDao.updateByPrimaryKey(pipe);
  104. }
  105. public void pdSnIdEnIdExPid(DPipeMapper dPipeDao,Integer snId,Integer enId,Integer pid) throws BusinessException {
  106. DPipeSQLBuilder sb =new DPipeSQLBuilder();
  107. DPipeSQLBuilder.Criteria sc = sb.createCriteria();
  108. sc.andSnidEqualTo(snId);
  109. sc.andEnidEqualTo(enId);
  110. sc.andIdNotEqualTo(pid);
  111. DPipe pip = dPipeDao.selectOneByExample(sb);
  112. if(pip!=null){
  113. throw new BusinessException("EB3100001");
  114. }
  115. }
  116. private void savePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType,
  117. String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5,
  118. String code,String roughCoeName ,SysFile gf,SysFile bf) {
  119. DPipe pipe =new DPipe();
  120. pipe.setName(name);
  121. pipe.setSnid(snId);
  122. pipe.setEnid(enId);
  123. pipe.setRoughCoe(Float.valueOf(roughCoe));
  124. pipe.setSectionType(sectionType);
  125. pipe.setSectionPara1(Float.valueOf(!StringUtil.isEmpty(sectionPara1)?sectionPara1:"0"));
  126. pipe.setSectionPara2(Float.valueOf(!StringUtil.isEmpty(sectionPara2)?sectionPara2:"0"));
  127. pipe.setSectionPara3(Float.valueOf(!StringUtil.isEmpty(sectionPara3)?sectionPara3:"0"));
  128. pipe.setSectionPara4(Float.valueOf(!StringUtil.isEmpty(sectionPara4)?sectionPara4:"0"));
  129. pipe.setSectionPara5(Float.valueOf(!StringUtil.isEmpty(sectionPara5)?sectionPara5:"0"));
  130. pipe.setCode(code);
  131. if(gf!=null){
  132. pipe.setGfid(gf.getId());
  133. pipe.setGfname(gf.getFilename());
  134. }
  135. if(bf!=null){
  136. pipe.setBfid(bf.getId());
  137. pipe.setBfname(bf.getFilename());
  138. }
  139. pipe.setRoughCoeName(roughCoeName);
  140. dPipeDao.insertSelective(pipe);
  141. }
  142. public void pdSnIdEnId(DPipeMapper dPipeDao,Integer snId,Integer enId) throws BusinessException {
  143. DPipeSQLBuilder sb =new DPipeSQLBuilder();
  144. DPipeSQLBuilder.Criteria sc = sb.createCriteria();
  145. sc.andSnidEqualTo(snId);
  146. sc.andEnidEqualTo(enId);
  147. DPipe pip = dPipeDao.selectOneByExample(sb);
  148. if(pip!=null){
  149. throw new BusinessException("EB3100001");
  150. }
  151. }
  152. /**
  153. * 基础系统,“管道数据添加修改”业务前处理
  154. */
  155. public void preTransFlow() throws Exception {
  156. this.validater();
  157. }
  158. /**
  159. * 基础系统,“管道数据添加修改”业务后处理
  160. */
  161. public void afterTransFlow() throws Exception {
  162. }
  163. /**
  164. * 基础系统,“管道数据添加修改”逻辑入口处理方法
  165. */
  166. @SuppressWarnings("rawtypes")
  167. @Override
  168. public Map execute(Map vars) throws Exception {
  169. this.setTransMap(vars);
  170. preTransFlow();// 执行业务开始的规则检查和校验
  171. transExecute();// 执行核心业务段
  172. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  173. return this.getTransMap();
  174. }
  175. }