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.SysFile; import com.miniframe.model.system.dao.DNodeMapper; import com.miniframe.model.system.dao.DPipeMapper; import com.miniframe.model.system.dao.SysFileMapper; import tk.mybatis.mapper.util.StringUtil; /** * 基础系统,“管道数据添加修改”逻辑处理(重新生成不覆盖)。 */ 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(); String roughCoeName=this.getA_d10002().getRoughCoeName(); String code =this.getA_d10002().getCode(); String gfid = this.getA_d10002().getGfid(); String bfid = this.getA_d10002().getBfid(); SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class); SysFile gf = sysFileMapper.selectByPrimaryKey(gfid); // if (gf == null) { //// throw new BusinessException("EB3100020"); // } SysFile bf = sysFileMapper.selectByPrimaryKey(bfid); // if (bf == null) { //// throw new BusinessException("EB3100021"); // } DNodeMapper nodeMapper =UtilTools.getBean(DNodeMapper.class); DNode sNode = nodeMapper.selectByPrimaryKey(snId); DNode eNode = nodeMapper.selectByPrimaryKey(enId); if(sNode==null || eNode==null){ throw new BusinessException("EB3000001"); } if(pid ==null || pid<=0){//添加 pdSnIdEnId(dPipeDao,snId,enId); savePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5,code,roughCoeName,gf,bf); }else{//修改 DPipe pipe =dPipeDao.selectByPrimaryKey(pid); pdSnIdEnIdNotPid(dPipeDao,snId,enId,pid); if(pipe==null){ throw new BusinessException("EB3100002"); } updatePipe(dPipeDao, name, snId, enId, roughCoe, sectionType, sectionPara1, sectionPara2, sectionPara3, sectionPara4, sectionPara5,roughCoeName, pipe,code,gf,bf); } } public void pdSnIdEnIdNotPid(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 updatePipe(DPipeMapper dPipeDao, String name, Integer snId, Integer enId, String roughCoe, String sectionType, String sectionPara1, String sectionPara2, String sectionPara3, String sectionPara4, String sectionPara5,String roughCoeName, DPipe pipe,String code,SysFile gf,SysFile bf) { pipe.setName(name); pipe.setSnid(snId); pipe.setEnid(enId); pipe.setRoughCoe(Float.valueOf(roughCoe)); pipe.setSectionType(sectionType); pipe.setSectionPara1(Float.valueOf(!StringUtil.isEmpty(sectionPara1)?sectionPara1:"0")); pipe.setSectionPara2(Float.valueOf(!StringUtil.isEmpty(sectionPara2)?sectionPara2:"0")); pipe.setSectionPara3(Float.valueOf(!StringUtil.isEmpty(sectionPara3)?sectionPara3:"0")); pipe.setSectionPara4(Float.valueOf(!StringUtil.isEmpty(sectionPara4)?sectionPara4:"0")); pipe.setSectionPara5(Float.valueOf(!StringUtil.isEmpty(sectionPara5)?sectionPara5:"0")); pipe.setCode(code); pipe.setRoughCoeName(roughCoeName); if(gf!=null){ pipe.setGfid(gf.getId()); pipe.setGfname(gf.getFilename()); } if(bf!=null){ pipe.setBfid(bf.getId()); pipe.setBfname(bf.getFilename()); } 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, String code,String roughCoeName ,SysFile gf,SysFile bf) { 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(!StringUtil.isEmpty(sectionPara1)?sectionPara1:"0")); pipe.setSectionPara2(Float.valueOf(!StringUtil.isEmpty(sectionPara2)?sectionPara2:"0")); pipe.setSectionPara3(Float.valueOf(!StringUtil.isEmpty(sectionPara3)?sectionPara3:"0")); pipe.setSectionPara4(Float.valueOf(!StringUtil.isEmpty(sectionPara4)?sectionPara4:"0")); pipe.setSectionPara5(Float.valueOf(!StringUtil.isEmpty(sectionPara5)?sectionPara5:"0")); pipe.setCode(code); if(gf!=null){ pipe.setGfid(gf.getId()); pipe.setGfname(gf.getFilename()); } if(bf!=null){ pipe.setBfid(bf.getId()); pipe.setBfname(bf.getFilename()); } pipe.setRoughCoeName(roughCoeName); 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(); } }