D10000Service.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. if(nid ==null || nid<=0){//添加
  29. pdXYZ(dNodeDao, x, y, z);
  30. saveNode(dNodeDao, x, y, z, name, ntype, desc);
  31. }else{//修改
  32. DNode node =findById(dNodeDao, nid);
  33. pdXYZExId(dNodeDao,x,y,z,nid);
  34. updateNode(dNodeDao, x, y, z, name, ntype, desc, node);
  35. }
  36. }
  37. private void updateNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc, DNode node) {
  38. node.setName(name);
  39. node.setnDesc(desc);
  40. node.setNtype(ntype);
  41. node.setX(Float.valueOf(x));
  42. node.setY(Float.valueOf(y));
  43. node.setZ(Float.valueOf(z));
  44. dNodeDao.updateByPrimaryKey(node);
  45. }
  46. private void saveNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc) {
  47. DNode node =new DNode();
  48. node.setName(name);
  49. node.setnDesc(desc);
  50. node.setNtype(ntype);
  51. node.setX(Float.valueOf(x));
  52. node.setY(Float.valueOf(y));
  53. node.setZ(Float.valueOf(z));
  54. dNodeDao.insertSelective(node);
  55. }
  56. private void pdXYZExId(DNodeMapper dNodeDao, String x, String y, String z,Integer nid) throws BusinessException {
  57. DNodeSQLBuilder sb =new DNodeSQLBuilder();
  58. DNodeSQLBuilder.Criteria sc =sb.createCriteria();
  59. sc.andXEqualTo(Float.valueOf(x));
  60. sc.andYEqualTo(Float.valueOf(y));
  61. sc.andZEqualTo(Float.valueOf(z));
  62. sc.andIdNotEqualTo(nid);
  63. int conut = dNodeDao.selectCountByExample(sb);
  64. if(conut>0){//已存在不能添加
  65. throw new BusinessException("EB3100000");
  66. }
  67. }
  68. private DNode findById(DNodeMapper dNodeDao, Integer nid) throws BusinessException {
  69. DNode node = dNodeDao.selectByPrimaryKey(nid);
  70. if(node ==null){
  71. throw new BusinessException("EB3000001");
  72. }
  73. return node;
  74. }
  75. private void pdXYZ(DNodeMapper dNodeDao, String x, String y, String z) throws BusinessException {
  76. DNodeSQLBuilder sb =new DNodeSQLBuilder();
  77. DNodeSQLBuilder.Criteria sc =sb.createCriteria();
  78. sc.andXEqualTo(Float.valueOf(x));
  79. sc.andYEqualTo(Float.valueOf(y));
  80. sc.andZEqualTo(Float.valueOf(z));
  81. int conut = dNodeDao.selectCountByExample(sb);
  82. if(conut>0){//已存在不能添加
  83. throw new BusinessException("EB3100000");
  84. }
  85. }
  86. /**
  87. * 基础系统,“节点数据添加修改”业务前处理
  88. */
  89. public void preTransFlow() throws Exception {
  90. this.validater();
  91. }
  92. /**
  93. * 基础系统,“节点数据添加修改”业务后处理
  94. */
  95. public void afterTransFlow() throws Exception {
  96. }
  97. /**
  98. * 基础系统,“节点数据添加修改”逻辑入口处理方法
  99. */
  100. @SuppressWarnings("rawtypes")
  101. @Override
  102. public Map execute(Map vars) throws Exception {
  103. this.setTransMap(vars);
  104. preTransFlow();// 执行业务开始的规则检查和校验
  105. transExecute();// 执行核心业务段
  106. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  107. return this.getTransMap();
  108. }
  109. }