123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- package com.huimv.xt.dao;
- import com.huimv.busi.base.dto.ResponseBean;
- import com.huimv.busi.xt.constant.XtAppConstant;
- import com.huimv.busi.xt.constant.XtSqlMapConstant;
- import com.huimv.web.base.PageBean;
- import com.huimv.xt.dataobject.XtDmlb;
- import com.huimv.xt.dataobject.XtDmlbExample;
- import com.ibatis.sqlmap.client.SqlMapExecutor;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import org.springframework.orm.ibatis.SqlMapClientCallback;
- import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
- public class XtDmlbDAOImpl extends SqlMapClientDaoSupport implements XtDmlbDAO {
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public XtDmlbDAOImpl() {
- super();
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int countByExample(XtDmlbExample example) {
- Integer count = (Integer) getSqlMapClientTemplate().queryForObject("xt_dmlb.ibatorgenerated_countByExample", example);
- return count;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int deleteByExample(XtDmlbExample example) {
- int rows = getSqlMapClientTemplate().delete("xt_dmlb.ibatorgenerated_deleteByExample", example);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int deleteByPrimaryKey(Integer lbid) {
- XtDmlb key = new XtDmlb();
- key.setLbid(lbid);
- int rows = getSqlMapClientTemplate().delete("xt_dmlb.ibatorgenerated_deleteByPrimaryKey", key);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public void insert(XtDmlb record) {
- getSqlMapClientTemplate().insert("xt_dmlb.ibatorgenerated_insert", record);
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public void insertSelective(XtDmlb record) {
- getSqlMapClientTemplate().insert("xt_dmlb.ibatorgenerated_insertSelective", record);
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- @SuppressWarnings("unchecked")
- public List<XtDmlb> selectByExample(XtDmlbExample example) {
- List<XtDmlb> list = getSqlMapClientTemplate().queryForList("xt_dmlb.ibatorgenerated_selectByExample", example);
- return list;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public XtDmlb selectByPrimaryKey(Integer lbid) {
- XtDmlb key = new XtDmlb();
- key.setLbid(lbid);
- XtDmlb record = (XtDmlb) getSqlMapClientTemplate().queryForObject("xt_dmlb.ibatorgenerated_selectByPrimaryKey", key);
- return record;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByExampleSelective(XtDmlb record, XtDmlbExample example) {
- UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
- int rows = getSqlMapClientTemplate().update("xt_dmlb.ibatorgenerated_updateByExampleSelective", parms);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByExample(XtDmlb record, XtDmlbExample example) {
- UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
- int rows = getSqlMapClientTemplate().update("xt_dmlb.ibatorgenerated_updateByExample", parms);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByPrimaryKeySelective(XtDmlb record) {
- int rows = getSqlMapClientTemplate().update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", record);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByPrimaryKey(XtDmlb record) {
- int rows = getSqlMapClientTemplate().update("xt_dmlb.ibatorgenerated_updateByPrimaryKey", record);
- return rows;
- }
- /**
- * This class was generated by Apache iBATIS ibator.
- * This class corresponds to the database table xt_dmlb
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- private static class UpdateByExampleParms extends XtDmlbExample {
- private Object record;
- public UpdateByExampleParms(Object record, XtDmlbExample example) {
- super(example);
- this.record = record;
- }
- public Object getRecord() {
- return record;
- }
- }
-
- /**
- * 根据参数搜索XtDmlb
- *
- * @return
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- public ResponseBean selectXtDmlbByParam(Map<String, Object> paramMap, PageBean pageBean) throws Exception {
- ResponseBean rb = new ResponseBean();
- List<XtDmlb> xtDmlbs = new ArrayList<XtDmlb>();
- int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_DMLB_BY_PARAM, paramMap);
-
- if(null != pageBean) {
- int startRecord = pageBean.getCurrentPageFirstRecord();
- int endRecord = pageBean.getPageSize();
- paramMap.put("startRecord", startRecord);
- paramMap.put("endRecord", endRecord);
- pageBean.setRecordCount(count);
- } else {
- paramMap.put("startRecord", 0);
- paramMap.put("endRecord", count);
- }
- xtDmlbs = (List<XtDmlb>) getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_DMLB_BY_PARAM, paramMap);
- rb.setResult(xtDmlbs);
- rb.setReturnCode(count);
- return rb;
- }
-
- /**
- * 找到最大的sxh
- */
- public Integer selectMaxSxh() {
- return (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_DMLB_BY_PARAM, null);
- }
-
- /**
- * 插入XtDmlb,同时更新对应XtDmlb的sxh字段
- * @param XtDmlb
- * 需要插入的XtDmlb
- */
- public void insertXtDmlb(final XtDmlb xtDmlb) {
- XtDmlbExample dmlbEx = new XtDmlbExample();
- dmlbEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID);
- final List<XtDmlb> xtDmlbs = selectByExample(dmlbEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- for (XtDmlb yXtDmlb : xtDmlbs) {
- if(yXtDmlb.getSxh() >= xtDmlb.getSxh()) {
- yXtDmlb.setSxh(yXtDmlb.getSxh() + 1);
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", yXtDmlb);
- }
- }
- executor.insert("xt_dmlb.ibatorgenerated_insertSelective", xtDmlb);
- executor.executeBatch();
- return null;
- }
- });
- }
-
- /**
- * 更新XtDmlb,同时更新对应XtDmlb的sxh字段
- * @param yXtDmlb
- * 原XtDmlb
- * @param xXtDmlb
- * 新XtDmlb
- */
- public void updateXtDmlb(final XtDmlb yXtDmlb, final XtDmlb xXtDmlb) {
- XtDmlbExample dmlbEx = new XtDmlbExample();
- dmlbEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID);
- final List<XtDmlb> xtDmlbs = selectByExample(dmlbEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- if(xXtDmlb.getSxh() > yXtDmlb.getSxh()) { //顺序号增加
- for (XtDmlb xtDmlb : xtDmlbs) {
- if(xtDmlb.getSxh() > yXtDmlb.getSxh() && xtDmlb.getSxh() <= xXtDmlb.getSxh()) {
- xtDmlb.setSxh(xtDmlb.getSxh() - 1);
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", xtDmlb);
- }
- }
- updateByPrimaryKeySelective(xXtDmlb);
- } else if (xXtDmlb.getSxh() < yXtDmlb.getSxh()) { //顺序号减小
- for (XtDmlb xtDmlb : xtDmlbs) {
- if(xtDmlb.getSxh() < yXtDmlb.getSxh() && xtDmlb.getSxh() >= xXtDmlb.getSxh()) {
- xtDmlb.setSxh(xtDmlb.getSxh() + 1);
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", xtDmlb);
- }
- }
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", xXtDmlb);
- }
- executor.executeBatch();
- return null;
- }
- });
- }
-
- /**
- * 置废XtDmlb,同时更新对应XtDmlb的sxh字段
- * @param xtDmlb
- * 需要置废的XtDmlb
- */
- public void disableXtDmlb(final XtDmlb xtDmlb) {
- XtDmlbExample dmlbEx = new XtDmlbExample();
- dmlbEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID);
- final List<XtDmlb> xtDmlbs = selectByExample(dmlbEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- for (XtDmlb dmlb : xtDmlbs) {
- if(dmlb.getSxh() > xtDmlb.getSxh()) {
- dmlb.setSxh(dmlb.getSxh() - 1);
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", dmlb);
- }
- }
- executor.update("xt_dmlb.ibatorgenerated_updateByPrimaryKeySelective", xtDmlb);
- executor.executeBatch();
- return null;
- }
- });
- }
- }
|