123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package com.miniframe.bisiness.system;
- import java.util.Map;
- import com.miniframe.core.ExecProcessFlow;
- import com.miniframe.core.exception.BusinessException;
- import com.miniframe.core.ext.UtilTools;
- import com.miniframe.generate.business.system.model.D10000BaseModel;
- import com.miniframe.model.system.DNode;
- import com.miniframe.model.system.DNodeSQLBuilder;
- import com.miniframe.model.system.dao.DNodeMapper;
- import com.miniframe.model.system.dao.DNodeValMapper;
- /**
- * 基础系统,“节点数据添加修改”逻辑处理(重新生成不覆盖)。
- */
- public class D10000Service extends D10000BaseModel implements ExecProcessFlow {
-
- private static final long serialVersionUID = -7051358269847459502L;
-
- /**
- * 基础系统,“节点数据添加修改”业务核心处理
- */
- public void transExecute() throws Exception {
- DNodeMapper dNodeDao = UtilTools.getBean(DNodeMapper.class);
- Integer nid = this.getA_d10000().getNid();
- String x =this.getA_d10000().getX();
- String y =this.getA_d10000().getY();
- String z =this.getA_d10000().getZ();
- String name =this.getA_d10000().getName();
- String ntype =this.getA_d10000().getNtype();
- String desc =this.getA_d10000().getDesc();
- if(nid ==null || nid<=0){//添加
- pdXYZ(dNodeDao, x, y, z);
- saveNode(dNodeDao, x, y, z, name, ntype, desc);
- }else{//修改
- DNode node =findById(dNodeDao, nid);
- pdXYZExId(dNodeDao,x,y,z,nid);
- updateNode(dNodeDao, x, y, z, name, ntype, desc, node);
- }
- }
- private void updateNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc, DNode node) {
- node.setName(name);
- node.setnDesc(desc);
- node.setNtype(ntype);
- node.setX(Float.valueOf(x));
- node.setY(Float.valueOf(y));
- node.setZ(Float.valueOf(z));
- dNodeDao.updateByPrimaryKey(node);
- }
- private void saveNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc) {
- DNode node =new DNode();
- node.setName(name);
- node.setnDesc(desc);
- node.setNtype(ntype);
- node.setX(Float.valueOf(x));
- node.setY(Float.valueOf(y));
- node.setZ(Float.valueOf(z));
- dNodeDao.insertSelective(node);
- }
- private void pdXYZExId(DNodeMapper dNodeDao, String x, String y, String z,Integer nid) throws BusinessException {
- DNodeSQLBuilder sb =new DNodeSQLBuilder();
- DNodeSQLBuilder.Criteria sc =sb.createCriteria();
- sc.andXEqualTo(Float.valueOf(x));
- sc.andYEqualTo(Float.valueOf(y));
- sc.andZEqualTo(Float.valueOf(z));
- sc.andIdNotEqualTo(nid);
- int conut = dNodeDao.selectCountByExample(sb);
- if(conut>0){//已存在不能添加
- throw new BusinessException("EB3100000");
- }
- }
- private DNode findById(DNodeMapper dNodeDao, Integer nid) throws BusinessException {
- DNode node = dNodeDao.selectByPrimaryKey(nid);
- if(node ==null){
- throw new BusinessException("EB3000001");
- }
- return node;
- }
- private void pdXYZ(DNodeMapper dNodeDao, String x, String y, String z) throws BusinessException {
- DNodeSQLBuilder sb =new DNodeSQLBuilder();
- DNodeSQLBuilder.Criteria sc =sb.createCriteria();
- sc.andXEqualTo(Float.valueOf(x));
- sc.andYEqualTo(Float.valueOf(y));
- sc.andZEqualTo(Float.valueOf(z));
- int conut = dNodeDao.selectCountByExample(sb);
- if(conut>0){//已存在不能添加
- throw new BusinessException("EB3100000");
- }
- }
- /**
- * 基础系统,“节点数据添加修改”业务前处理
- */
- public void preTransFlow() throws Exception {
- this.validater();
- }
-
- /**
- * 基础系统,“节点数据添加修改”业务后处理
- */
- public void afterTransFlow() throws Exception {
-
- }
-
- /**
- * 基础系统,“节点数据添加修改”逻辑入口处理方法
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Map execute(Map vars) throws Exception {
- this.setTransMap(vars);
- preTransFlow();// 执行业务开始的规则检查和校验
- transExecute();// 执行核心业务段
- afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
- return this.getTransMap();
- }
- }
|