笔迹.md

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#JAVA##数据库操作###Hibernate操作å�¯æ¹æ®å¡«è¡¨å•ä½ç¼–卷过滤数据以半拼接查询语卥」拼接查询卂数。```javaStringBufferhql=newStringBuffer();ListObjectparams=newArrayListObject();hql.append(FromRyMqryxxasryxxWhereryxx.scbz!='1'andryxx.tbdwbhlike?);params.add(COMMON.makeDwbhLike(curUser.getTbdwbh()));//所在单位半下属单位if(!COMMON.empty(queryInfo.getRjlx())){hql.append(andryxx.rjlx=?);params.add(queryInfo.getRjlx());}眍略...returnthis.find(page,hql.toString(),,params.toArray());```eecmisws,接卣kz_queryOfficialBatch部分代ç�```java//æž„é€æŸ¥è¯¢æ�¡ä»¶StringBuffersql=newStringBuffer();ListObjectsqlv=newArrayListObject();sql.append(fromKzGjgzryjbxxtwhere1=1);//登记单位不为空时,进行捡件拼接if(!HxStringUtil.isEmpty(tbdwbh)){if(tbdwbh.length()==12){sql.append(and(t.tbdwbh=?));sqlv.add(tbdwbh);}else{sql.append(String.format(and(t.tbdwbhlike'%s%%'),SqlStringUtil.escapeByLike(tbdwbh)));}}//结损时间ä¸�为空时,进行捡件拼接if(null!=timeend){sql.append(String.format(and%s=cast(?asdate),timeField));sqlv.add(timeend);}ListKzGjgzryjbxxlstsrc=(ListKzGjgzryjbxx)this.queryDBList(start,limit,sql.toString(),sqlv.toArray());```queryJdbcKajqdTotal方法```javaif(!COMMON.empty(queryInfo.getDateBegin())){hql.append(ANDlrsj=TO_DATE(').append(COMMON.formatDate(queryInfo.getDateBegin())).append(','YYYYMMDD'));}if(!COMMON.empty(queryInfo.getDateEnd())){//hql.append(andlrsj).append(queryInfo.getDateEnd());hql.append(ANDlrsj=TO_DATE(').append(COMMON.formatDate(DateUtils.afterDate(queryInfo.getDateEnd(),1))).append(','YYYYMMDD'));}眍略...returnthis.getJdbcTemplate().queryForList(hql.toString());``````javapublicList?queryDBPjcxList(Pagepage,PjcxQueryInfoinfo){if(COMMON.empty(info)){returnCollections.emptyList();}ListObjectparams=newArrayListObject();StringBuffersql=newStringBuffer(fromPjEvaluationInfowherescbz1);if(COMMON.notEmpty(info.getFromTime())){sql.append(andpjsj=to_date(?,'YYYYMMDD'));params.add(COMMON.formatDate(info.getFromTime()));}if(COMMON.notEmpty(info.getToTime())){sql.append(andpjsjto_date(?,'YYYYMMDD'));params.add(COMMON.formatDate(COMMON.addNowDay(info.getToTime(),1)));}眍略...returnthis.find(page,sql.toString(),params.toArray());}``````javaif(!COMMON.empty(queryModel.getSldw())){if(1.equals(queryModel.getSfckxj())){hql.append(andt1.sldwlike'+COMMON.makeDwbhLike(queryModel.getSldw())+');}elseif(0.equals(queryModel.getSfckxj())){hql.append(andt1.sldwlike'+queryModel.getSldw()+%');}}``````javaKajqdjbxxitem=newKajqdjbxx();item.setScbz(0);this.getHibernateTemplate().saveOrUpdate(item);``````java//querylist.hql.append())awhererownum=?)wherern=?);hqlv.add(lastindex);hqlv.add(startindex);headSql=headSql+hql.toString();//ListDonelistlistSrc=(ListDonelist)this.queryDBList(startindex,limit,distinctsqId+hql.toString(),hqlv.toArray());ListMapString,ObjectlistSrc=this.getSpringEecmisDao().queryDBForList(headSql,hqlv.toArray());```###æ›´æ–°ã€�俍存```java/*if(dzxx.getTbdwbh()==null)dzxx.setTbdwbh(user.getYhUser().getTbdwbh());*/if(COMMON.empty(item.getLrsj())){item.setLrr(curUser.getUserId());item.setZhxgr(curUser.getUserId());}else{item.setZhxgr(curUser.getUserId());}this.getHibernateTemplate().save();this.getHibernateTemplate().saveOrUpdate();this.getHibernateTemplate().update();``````Stringhql=fromJhZjWbsjrkqkwhereywbh=?;List?wbsjrkqkList=wsCommonService.queryDBList(hql,newObject[]{ywbh});if(wbsjrkqkList.size()0){JhZjWbsjrkqkwbsjrkqk=(JhZjWbsjrkqk)wbsjrkqkList.get(0);}```###JSON操作```javaMapString,DateFormatdataformats=newHashMapString,DateFormat();dataformats.put(csrq,newSimpleDateFormat(yyyyMMdd));//出生日期,日期æ¼å¼�yyyyMMdd.JSONArraylstpj=HzJsonUtil.toJSONArray(lstsrc,dataformats);//整体将数据转为JSON,然华再åŠå·¥.HzJsonUtil.renameField(jsonObj,oldname,newname,HzJsonUtil.NAMEMODE_DEFAULT);//重命卍字段HzJsonUtil.copyField(dest,src,field1,field2,field3,HzJsonUtil.NAMEMODE_IGNORE_CASE);//copyHzJsonUtil.nullToEmptyString(json,ZWXM,SFZH,CSRQ);//å°†json中的null值转为空字符串optå’Œget方法的区别,如getJSONObjectå’ŒoptJSONobject();get方法会抛异常,opt方法不抛异常。```###limitã€�offset```sqlSELECT*FROMCOMPANYLIMIT6//降制由SELECT语卥返回的数据数重,降制返回6捡数据。select*fromtablelimit2,1;//卫义是跳过2捡卖出1捡数据,limit华鍢是从第2捡开始读,读卖1捡信捯,即读卖第3捡数据SELECT*FROMCOMPANYLIMIT3OFFSET2;//从一个特定的卍移开始捍卖记录,从第三位开始æ��å�–3个记录```###字典相关```javapublicStringgetZdms(Stringkind,Stringcode,Stringzdms){Stringdetail=HZdb.getZdms(kind,code,zdms);if(detail==null)returncode;returndetail;}```###```javainputtype=hnisi/buttonvalue=修改onclick=$('#save').click();CommonUtils.closeModal('xg');/``````申领单位曾绍使用的是702字典(6位),现在使用的是701字典(12位)。tbdwbh也有用700的。``````Eclipse相关配置:JavaBuildPathJavaCompi

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功