📄 codetableserviceimpl.java
字号:
//Source file: D:\\航务局项目\\源程序\\com\\olive\\dmwh\\service\\CodeTableServiceImpl.javapackage com.wygl.dmwh.service;import java.util.List;import com.wygl.dmwh.domain.CodeNavigation;import com.wygl.dmwh.domain.CodeTableEdit;import com.wygl.dmwh.domain.CodeCheck;import com.wygl.page.Condition;import com.wygl.page.HQuery;import com.wygl.page.ParasList;import com.wygl.service.AbstractService;/** * 代码表服务实现 */public class CodeTableServiceImpl extends AbstractService implements CodeTableService { public boolean modify(Object object) throws Exception { try { dbDao.updateObject(object); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean save(Object object) throws Exception { try { dbDao.addObject(object); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean delete(String ct_id) throws Exception { try { if(ct_id != null && !ct_id.equals("")){ //调用删除校验代码 CodeTableEdit codeTableEdit = (CodeTableEdit)dbDao.queryObjectById(CodeTableEdit.class,ct_id); System.out.println(" from CodeCheck as codeCheck where codeCheck.codeType='"+codeTableEdit.getCodeType()+"'"); List list = dbDao.queryObjects(" from CodeCheck as codeCheck where codeCheck.codeType='"+codeTableEdit.getCodeType()+"'"); for(int i=0;i<list.size();i++){ CodeCheck codeCheck = (CodeCheck)list.get(i); int size = ((Integer)dbDao.queryObjects(codeCheck.getHqlString()+codeTableEdit.getCt_id()+"'").iterator().next()).intValue(); if(size>0){ throw new Exception(codeCheck.getErrMessage()); } } //删除代码 List delList = dbDao.queryObjects(" from CodeTableEdit as codeTableEdit where codeTableEdit.fatherCode like '"+ct_id+"%'"); for(int i=0;i<delList.size();i++){ CodeTableEdit delCodeTableEdit = (CodeTableEdit)delList.get(i); dbDao.deleteObject(CodeTableEdit.class,delCodeTableEdit.getCt_id()); } dbDao.deleteObject(CodeTableEdit.class,ct_id); }else{ return false; } return true; } catch (Exception e) { throw new Exception(e.getMessage()); } } public List queryCodeTable(String cn_id,String codeType,String fatherCode,String layer,String layerRule,String isDept,String dept_id) throws Exception { try { int levels = Integer.parseInt(layer); int curLayer = Integer.parseInt(layerRule.substring(levels-1,levels)); String likeStr = ""; for(int i = 0;i<curLayer;i++){ likeStr += "_"; } String hqlstring = ""; if(isDept.equals("0")){ hqlstring = " from CodeTableEdit as codeTableEdit where codeTableEdit.codeNavigation.cn_id='"+cn_id+"' and codeTableEdit.ct_id <> '"+codeType+"' and codeTableEdit.ct_id like '"+fatherCode+likeStr+"' and codeTableEdit.dept_id = '"+dept_id+"' order by codeTableEdit.codeNavigation.cn_id asc,codeTableEdit.code asc "; }else{ hqlstring = " from CodeTableEdit as codeTableEdit where codeTableEdit.codeNavigation.cn_id='"+cn_id+"' and codeTableEdit.ct_id <> '"+codeType+"' and codeTableEdit.ct_id like '"+fatherCode+likeStr+"' order by codeTableEdit.codeNavigation.cn_id asc,codeTableEdit.code asc "; } return dbDao.queryObjects(hqlstring); } catch (Exception e) { e.printStackTrace(); return null; } } public List query(String whereString) throws Exception { try { return dbDao.queryObjects("from CodeTable as codeTable "+whereString); } catch (Exception e) { e.printStackTrace(); return null; } } public Object queryNavigateById(String cn_id) throws Exception { try { if(cn_id == null || cn_id.equals("")){ return null; }else{ return dbDao.queryObjectById(CodeNavigation.class,cn_id); } } catch (Exception e) { e.printStackTrace(); return null; } } public List queryNavigate(String groupNo) throws Exception { try { hquery = new HQuery(); hquery.setQueryString("from CodeNavigation as codeNavigation where codeNavigation.isShow='0' and codeNavigation.groupNo="+groupNo); ParasList paraslist=new ParasList(); hquery.setParaslist(paraslist); //查询记录总数 int pagecount = dbDao.count(hquery); condition.setRowCounts(pagecount); condition.setCrossPages(Math.round(Math.ceil(pagecount*1.0/condition.getRowsPerpage()))); if(condition.getPageNo() > condition.getCrossPages()){ condition.setPageNo(condition.getCrossPages()); } long currentRow = (condition.getPageNo() - 1)*condition.getRowsPerpage(); if(currentRow < 0){ currentRow = 0; condition.setPageNo(1); } condition.setCurrentRow(currentRow + 1); //调用查寻方法得到第PageNo页结果 hquery.setPageStartNo(condition.getPageNo()); hquery.setOrderby(" order by codeNavigation.cn_id asc " ); return dbDao.queryObjectsToPages(hquery); } catch (Exception e) { e.printStackTrace(); return null; } } public Condition getCondition() { return this.condition; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -