123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- package com.huimv.xt.dao;
- 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;
- 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.XtGydm;
- import com.huimv.xt.dataobject.XtGydmExample;
- import com.huimv.xt.dataobject.XtGydmKey;
- import com.ibatis.sqlmap.client.SqlMapExecutor;
- public class XtGydmDAOImpl extends SqlMapClientDaoSupport implements XtGydmDAO {
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public XtGydmDAOImpl() {
- super();
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int countByExample(XtGydmExample example) {
- Integer count = (Integer) getSqlMapClientTemplate().queryForObject("xt_gydm.ibatorgenerated_countByExample", example);
- return count;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int deleteByExample(XtGydmExample example) {
- int rows = getSqlMapClientTemplate().delete("xt_gydm.ibatorgenerated_deleteByExample", example);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int deleteByPrimaryKey(XtGydmKey key) {
- int rows = getSqlMapClientTemplate().delete("xt_gydm.ibatorgenerated_deleteByPrimaryKey", key);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public void insert(XtGydm record) {
- getSqlMapClientTemplate().insert("xt_gydm.ibatorgenerated_insert", record);
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public void insertSelective(XtGydm record) {
- getSqlMapClientTemplate().insert("xt_gydm.ibatorgenerated_insertSelective", record);
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- @SuppressWarnings("unchecked")
- public List<XtGydm> selectByExample(XtGydmExample example) {
- List<XtGydm> list = getSqlMapClientTemplate().queryForList("xt_gydm.ibatorgenerated_selectByExample", example);
- return list;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public XtGydm selectByPrimaryKey(XtGydmKey key) {
- XtGydm record = (XtGydm) getSqlMapClientTemplate().queryForObject("xt_gydm.ibatorgenerated_selectByPrimaryKey", key);
- return record;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByExampleSelective(XtGydm record, XtGydmExample example) {
- UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
- int rows = getSqlMapClientTemplate().update("xt_gydm.ibatorgenerated_updateByExampleSelective", parms);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByExample(XtGydm record, XtGydmExample example) {
- UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
- int rows = getSqlMapClientTemplate().update("xt_gydm.ibatorgenerated_updateByExample", parms);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByPrimaryKeySelective(XtGydm record) {
- int rows = getSqlMapClientTemplate().update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", record);
- return rows;
- }
- /**
- * This method was generated by Apache iBATIS ibator.
- * This method corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- public int updateByPrimaryKey(XtGydm record) {
- int rows = getSqlMapClientTemplate().update("xt_gydm.ibatorgenerated_updateByPrimaryKey", record);
- return rows;
- }
- /**
- * This class was generated by Apache iBATIS ibator.
- * This class corresponds to the database table xt_gydm
- *
- * @ibatorgenerated Fri May 30 10:23:18 CST 2014
- */
- private static class UpdateByExampleParms extends XtGydmExample {
- private Object record;
- public UpdateByExampleParms(Object record, XtGydmExample example) {
- super(example);
- this.record = record;
- }
- public Object getRecord() {
- return record;
- }
- }
-
- @SuppressWarnings("unchecked")
- public List<XtGydm> selectBydmmc(XtGydm gydm) {
- List<XtGydm> list = (List<XtGydm>) getSqlMapClientTemplate()
- .queryForList("xt_gydm.abatorgenerated_selectBydmmc", gydm);
- return list;
- }
-
- /**
- * 根据参数搜索XtGydm
- *
- * @return
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- public ResponseBean selectXtGydmByParam(Map<String, Object> paramMap, PageBean pageBean) throws Exception {
- ResponseBean rb = new ResponseBean();
- List<XtGydm> xtGydms = new ArrayList<XtGydm>();
- int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_GYDM_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);
- }
- xtGydms = (List<XtGydm>) getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_GYDM_BY_PARAM, paramMap);
-
- rb.setResult(xtGydms);
- rb.setReturnCode(count);
- return rb;
- }
-
- /**
- * 搜索指定条件的XtGydm条数
- */
- public int countGydmByParam(Map<String, Object> paramMap) {
- return (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_GYDM_BY_PARAM, paramMap);
- }
-
- /**
- * 插入XtGydm并更新同类别下XtGydm.SXH
- * @param xtGydm
- * 需要插入的XtGydm
- */
- public void insertXtGydm(final XtGydm xtGydm) {
- XtGydmExample xtGydmEx = new XtGydmExample();
- xtGydmEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID).andLbidEqualTo(xtGydm.getLbid());
- final List<XtGydm> xtGydms = selectByExample(xtGydmEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- for (XtGydm gydm : xtGydms) {
- if(gydm.getSxh() >= xtGydm.getSxh()) {
- gydm.setSxh(gydm.getSxh() + 1);
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", gydm);
- }
- }
- executor.insert("xt_gydm.ibatorgenerated_insertSelective", xtGydm);
- executor.executeBatch();
- return null;
- }
- });
- }
-
- /**
- * 修改XtGydm,同时更新同lbid下的XtGydm.SXH
- * @param yXtGydm
- * 原XtGydm
- * @param xXtGydm
- * 新XtGydm
- */
- public void updateXtGydm(final XtGydm yXtGydm, final XtGydm xXtGydm) {
- XtGydmExample xtGydmEx = new XtGydmExample();
- xtGydmEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID).andLbidEqualTo(xXtGydm.getLbid());
- final List<XtGydm> xtGydms = selectByExample(xtGydmEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- if( xXtGydm.getSxh() > yXtGydm.getSxh() ) {
- for (XtGydm gydm : xtGydms) {
- if(gydm.getSxh() > yXtGydm.getSxh() && gydm.getSxh() <= xXtGydm.getSxh()) {
- gydm.setSxh(gydm.getSxh() - 1);
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", gydm);
- }
- }
- updateByPrimaryKeySelective(xXtGydm);
- } else if( xXtGydm.getSxh() < yXtGydm.getSxh() ) {
- for (XtGydm gydm : xtGydms) {
- if(gydm.getSxh() < yXtGydm.getSxh() && gydm.getSxh() >= xXtGydm.getSxh()) {
- gydm.setSxh(gydm.getSxh() + 1);
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", gydm);
- }
- }
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", xXtGydm);
- } else {
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", xXtGydm);
- }
- executor.executeBatch();
- return null;
- }
- });
- }
-
- /**
- * 置废XtGydm,同时更新同lbid的XtGydm.SXH
- * @param xtGydm
- * 需要置废的XtGydm
- */
- public void disableXtGydm(final XtGydm xtGydm) {
- XtGydmExample xtGydmEx = new XtGydmExample();
- xtGydmEx.createCriteria().andZfbzEqualTo(XtAppConstant.ZFBZ_VALID).andLbidEqualTo(xtGydm.getLbid());
- final List<XtGydm> xtGydms = selectByExample(xtGydmEx);
-
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
-
- @Override
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- for (XtGydm gydm : xtGydms) {
- if(gydm.getSxh() >= xtGydm.getSxh()) {
- gydm.setSxh(gydm.getSxh() - 1);
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", gydm);
- }
- }
- executor.update("xt_gydm.ibatorgenerated_updateByPrimaryKeySelective", xtGydm);
- executor.executeBatch();
- return null;
- }
- });
- }
-
- /**
- * 返回指定LBID中最大的DMID
- */
- public int selectMaxDmidByLbid(Integer lbid) {
- Integer count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_SELECT_MAX_GYDM_DMID_BY_LBID, lbid);
- return count == null ? 0 : count;
- }
-
- /**
- * 根据lbmc获取gydm
- */
- @SuppressWarnings("unchecked")
- public List<XtGydm> selectGydmByLbmc(String lbmc) {
- //TODO ZJ 修改 SQLMAP_SELECT_GYDM_BY_LBMC_NOLIKE 名称
- List<XtGydm> list = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_GYDM_BY_LBMC_NOLIKE, lbmc);
- return list;
- }
- }
|