D10000Service.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.D10000BaseModel;
  7. import com.miniframe.model.system.DNode;
  8. import com.miniframe.model.system.DNodeSQLBuilder;
  9. import com.miniframe.model.system.dao.DNodeMapper;
  10. import com.miniframe.model.system.dao.DNodeValMapper;
  11. /**
  12. * 基础系统,“节点数据添加修改”逻辑处理(重新生成不覆盖)。
  13. */
  14. public class D10000Service extends D10000BaseModel implements ExecProcessFlow {
  15. private static final long serialVersionUID = -7051358269847459502L;
  16. /**
  17. * 基础系统,“节点数据添加修改”业务核心处理
  18. */
  19. public void transExecute() throws Exception {
  20. DNodeMapper dNodeDao = UtilTools.getBean(DNodeMapper.class);
  21. Integer nid = this.getA_d10000().getNid();
  22. String x =this.getA_d10000().getX();
  23. String y =this.getA_d10000().getY();
  24. String z =this.getA_d10000().getZ();
  25. String name =this.getA_d10000().getName();
  26. String ntype =this.getA_d10000().getNtype();
  27. String desc =this.getA_d10000().getDesc();
  28. String code =this.getA_d10000().getCode();
  29. if(nid ==null || nid<=0){//添加
  30. pdXYZ(dNodeDao, x, y, z);
  31. saveNode(dNodeDao, x, y, z, name, ntype, desc,code);
  32. }else{//修改
  33. DNode node =findById(dNodeDao, nid);
  34. pdXYZExId(dNodeDao,x,y,z,nid);
  35. updateNode(dNodeDao, x, y, z, name, ntype, desc, node,code);
  36. }
  37. }
  38. private void updateNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc, DNode node,String code) {
  39. node.setName(name);
  40. node.setnDesc(desc);
  41. node.setNtype(ntype);
  42. node.setX(x);
  43. node.setY(y);
  44. node.setZ(z);
  45. node.setCode(code);
  46. dNodeDao.updateByPrimaryKey(node);
  47. }
  48. private void saveNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc,String code) {
  49. DNode node =new DNode();
  50. node.setName(name);
  51. node.setnDesc(desc);
  52. node.setNtype(ntype);
  53. node.setX(x);
  54. node.setY(y);
  55. node.setZ(z);
  56. node.setCode(code);
  57. dNodeDao.insertSelective(node);
  58. }
  59. private void pdXYZExId(DNodeMapper dNodeDao, String x, String y, String z,Integer nid) throws BusinessException {
  60. DNodeSQLBuilder sb =new DNodeSQLBuilder();
  61. DNodeSQLBuilder.Criteria sc =sb.createCriteria();
  62. sc.andXEqualTo(x);
  63. sc.andYEqualTo(y);
  64. sc.andZEqualTo(z);
  65. sc.andIdNotEqualTo(nid);
  66. int conut = dNodeDao.selectCountByExample(sb);
  67. if(conut>0){//已存在不能添加
  68. throw new BusinessException("EB3100000");
  69. }
  70. }
  71. private DNode findById(DNodeMapper dNodeDao, Integer nid) throws BusinessException {
  72. DNode node = dNodeDao.selectByPrimaryKey(nid);
  73. if(node ==null){
  74. throw new BusinessException("EB3000001");
  75. }
  76. return node;
  77. }
  78. private void pdXYZ(DNodeMapper dNodeDao, String x, String y, String z) throws BusinessException {
  79. DNodeSQLBuilder sb =new DNodeSQLBuilder();
  80. DNodeSQLBuilder.Criteria sc =sb.createCriteria();
  81. sc.andXEqualTo(x);
  82. sc.andYEqualTo(y);
  83. sc.andZEqualTo(z);
  84. int conut = dNodeDao.selectCountByExample(sb);
  85. if(conut>0){//已存在不能添加
  86. throw new BusinessException("EB3100000");
  87. }
  88. }
  89. /**
  90. * 基础系统,“节点数据添加修改”业务前处理
  91. */
  92. public void preTransFlow() throws Exception {
  93. this.validater();
  94. }
  95. /**
  96. * 基础系统,“节点数据添加修改”业务后处理
  97. */
  98. public void afterTransFlow() throws Exception {
  99. }
  100. /**
  101. * 基础系统,“节点数据添加修改”逻辑入口处理方法
  102. */
  103. @SuppressWarnings("rawtypes")
  104. @Override
  105. public Map execute(Map vars) throws Exception {
  106. this.setTransMap(vars);
  107. preTransFlow();// 执行业务开始的规则检查和校验
  108. transExecute();// 执行核心业务段
  109. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  110. return this.getTransMap();
  111. }
  112. }