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(); String code =this.getA_d10000().getCode(); if(nid ==null || nid<=0){//添加 pdXYZ(dNodeDao, x, y, z); saveNode(dNodeDao, x, y, z, name, ntype, desc,code); }else{//修改 DNode node =findById(dNodeDao, nid); pdXYZExId(dNodeDao,x,y,z,nid); updateNode(dNodeDao, x, y, z, name, ntype, desc, node,code); } } private void updateNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc, DNode node,String code) { node.setName(name); node.setnDesc(desc); node.setNtype(ntype); node.setX(x); node.setY(y); node.setZ(z); node.setCode(code); dNodeDao.updateByPrimaryKey(node); } private void saveNode(DNodeMapper dNodeDao, String x, String y, String z, String name, String ntype, String desc,String code) { DNode node =new DNode(); node.setName(name); node.setnDesc(desc); node.setNtype(ntype); node.setX(x); node.setY(y); node.setZ(z); node.setCode(code); 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(x); sc.andYEqualTo(y); sc.andZEqualTo(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(x); sc.andYEqualTo(y); sc.andZEqualTo(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(); } }