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.D10002BaseModel; import com.miniframe.model.system.DNode; import com.miniframe.model.system.DPipe; import com.miniframe.model.system.DPipeSQLBuilder; import com.miniframe.model.system.dao.DNodeMapper; import com.miniframe.model.system.dao.DPipeMapper; /** * 基础系统,“管道数据添加修改”逻辑处理(重新生成不覆盖)。 */ public class D10002Service extends D10002BaseModel implements ExecProcessFlow { private static final long serialVersionUID = -7051358269847459502L; /** * 基础系统,“管道数据添加修改”业务核心处理 */ public void transExecute() throws Exception { DPipeMapper dPipeDao = UtilTools.getBean(DPipeMapper.class); Integer pid = this.getA_d10002().getPid(); String name =this.getA_d10002().getName(); Integer snId = this.getA_d10002().getSnId(); Integer enId =this.getA_d10002().getEnId(); String roughCoe =this.getA_d10002().getRoughCoe(); String sectionType =this.getA_d10002().getSectionType(); String sectionPara1 =this.getA_d10002().getSectionPara1(); String sectionPara2 =this.getA_d10002().getSectionPara2(); String sectionPara3 =this.getA_d10002().getSectionPara3(); String sectionPara4 =this.getA_d10002().getSectionPara4(); String sectionPara5 =this.getA_d10002().getSectionPara5(); if(pid ==null || pid<=0){//添加 pdSnIdEnId(dPipeDao,snId,enId); savePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5); }else{//修改 DPipe pipe =dPipeDao.selectByPrimaryKey(pid); if(pipe==null){ throw new BusinessException("EB3100002"); } updatePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5, pipe); } } private void updatePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType, String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5, DPipe pipe) { pipe.setName(name); pipe.setSnid(snId); pipe.setEnid(enId); pipe.setRoughCoe(Float.valueOf(roughCoe)); pipe.setSectionType(sectionType); pipe.setSectionPara1(Float.valueOf(sectionPara1)); pipe.setSectionPara2(Float.valueOf(sectionPara2)); pipe.setSectionPara3(Float.valueOf(sectionPara3)); pipe.setSectionPara4(Float.valueOf(sectionPara4)); pipe.setSectionPara5(Float.valueOf(sectionPara5)); dPipeDao.updateByPrimaryKey(pipe); } public void pdSnIdEnIdExPid(DPipeMapper dPipeDao,Integer snId,Integer enId,Integer pid) throws BusinessException { DPipeSQLBuilder sb =new DPipeSQLBuilder(); DPipeSQLBuilder.Criteria sc = sb.createCriteria(); sc.andSnidEqualTo(snId); sc.andEnidEqualTo(enId); sc.andIdNotEqualTo(pid); DPipe pip = dPipeDao.selectOneByExample(sb); if(pip!=null){ throw new BusinessException("EB3100001"); } } private void savePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType, String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5) { DPipe pipe =new DPipe(); pipe.setName(name); pipe.setSnid(snId); pipe.setEnid(enId); pipe.setRoughCoe(Float.valueOf(roughCoe)); pipe.setSectionType(sectionType); pipe.setSectionPara1(Float.valueOf(sectionPara1!=null?sectionPara1:"0")); pipe.setSectionPara2(Float.valueOf(sectionPara2!=null?sectionPara2:"0")); pipe.setSectionPara3(Float.valueOf(sectionPara3!=null?sectionPara3:"0")); pipe.setSectionPara4(Float.valueOf(sectionPara4!=null?sectionPara4:"0")); pipe.setSectionPara5(Float.valueOf(sectionPara5!=null?sectionPara5:"0")); dPipeDao.insertSelective(pipe); } public void pdSnIdEnId(DPipeMapper dPipeDao,Integer snId,Integer enId) throws BusinessException { DPipeSQLBuilder sb =new DPipeSQLBuilder(); DPipeSQLBuilder.Criteria sc = sb.createCriteria(); sc.andSnidEqualTo(snId); sc.andEnidEqualTo(enId); DPipe pip = dPipeDao.selectOneByExample(sb); if(pip!=null){ throw new BusinessException("EB3100001"); } } /** * 基础系统,“管道数据添加修改”业务前处理 */ 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(); } }