裝置支援多箱號查詢,mybatis標籤
/**
* 查詢裝置資訊列表
*
* @param request
* @param response
* @return
*/
@RequestMapping("devList")
@ResponseBody
public List<OsmDev> orderList(HttpServletRequest request, HttpServletResponse response) throws Exception {
//專案編號
String projectid = request.getParameter("projectid");
//箱號
String boxnoStr = request.getParameter("boxno");
List<String> boxnoList = new ArrayList<String>();
if(boxnoStr !=null && !boxnoStr.equals("")){
String[] boxnoArr = boxnoStr.split(",");
for(String boxno : boxnoArr){
boxnoList.add(boxno);
}
}
//裝置編號
String deveui = request.getParameter("deveui");
deveui = (deveui == null) ? "" : deveui.trim();
deveui = deveui.trim().toLowerCase();
//發貨單編號
String ordNo = request.getParameter("ordNo");
//裝置型別
String devtype = request.getParameter("devtype");
//裝置狀態
String devStatusStr = request.getParameter("devStatus");
Integer devStatus=-1;
if(devStatusStr != null && !devStatusStr.trim().equals("")){
devStatus = Integer.parseInt(devStatusStr);
}
//登記開始時間
String beginTime = request.getParameter("beginTime");
String beginTimeFenmiao ="";
if(beginTime !=null && !beginTime.trim().equals("") ){
beginTimeFenmiao = beginTime + " "+"00:00:00";
}
//登記結束時間
String endTime = request.getParameter("endTime");
String endTimeFenmiao ="";
if(endTime !=null && !endTime.trim().equals("") ){
endTimeFenmiao = endTime + " "+"23:59:59";
}
logger.info("deveui = "+deveui+", ordNo="+ordNo+",devStatus="+devStatus+", beginTime="+beginTime+", finishdate="+endTime);
projectid = (projectid == null) ? "" : projectid.trim();
ordNo = (ordNo == null) ? "" : ordNo.trim();
devtype = (devtype == null) ? "" : devtype.trim();
deveui = (deveui == null) ? "" : deveui.trim();
beginTime = (beginTime == null) ? "" : beginTime.trim();
endTime = (endTime == null) ? "" : endTime.trim();
DevQueryPara para = genDevQryParam(projectid.trim(),deveui.trim(),ordNo.trim(), devtype.trim(),devStatus,beginTimeFenmiao, endTimeFenmiao,boxnoList);
return devService.queryAllOsmDevByPara(para);
}
private DevQueryPara genDevQryParam(String projectid,String deveui,String ordNo,String devtype,Integer devStatus,String beginTimeFenmiao,String endTimeFenmiao,List<String> boxnoList)
{
DevQueryPara para = new DevQueryPara();
para.setProjectid(projectid);
para.setDeveui(deveui);
para.setOrdNo(ordNo);
para.setDevType(devtype);
para.setDevStatus(devStatus);
para.setBeginDate(DateUtil.parseDatetime(beginTimeFenmiao));
para.setEndDate(DateUtil.parseDatetime(endTimeFenmiao));
para.setBoxnoList(boxnoList);
return para;
}
// 查詢OsmDev資訊
public List<OsmDev> queryAllOsmDevByPara(DevQueryPara p) throws Exception;
@Override
public List<OsmDev> queryAllOsmDevByPara(DevQueryPara p) throws Exception {
return this.devMapper.queryAllOsmDevByPara(p);
}
// 查詢OsmDev資訊
public List<OsmDev> queryAllOsmDevByPara(@Param("p") DevQueryPara p) throws Exception;
<select id="queryAllOsmDevByPara" resultType="com.zte.claa.infiboss.app.model.osm.OsmDev">
SELECT t.DEVEUI AS deveui,
t.DEVTYPE AS devType,
t.ORDNO AS ordNo,
t.CLAANO AS claaNo,
t.DEVSTATUS AS devStatus,
t.OPTIME AS opTime,
t.REMARK AS remark,
t.PROJECTID AS projectid,
t.ADDRESS AS address,
t.GPSLAT AS gpslat,
t.GPSLNG AS gpslng,
t.GPSALT AS gpsalt,
t.BOXNO AS boxno
FROM osmdb.t_osm_dev t
WHERE 1 = 1
<if test='p.projectid != null and p.projectid != "" '>
AND t.PROJECTID = #{p.projectid, jdbcType=VARCHAR}
</if>
<if test='p.devType != null and p.devType != "" '>
AND t.DEVTYPE = #{p.devType, jdbcType=VARCHAR}
</if>
<if test='p.deveui != null and p.deveui != "" '>
AND t.DEVEUI = #{p.deveui, jdbcType=VARCHAR}
</if>
<if test='p.ordNo != null and p.ordNo != "" '>
AND t.DEVEUI IN (SELECT DISTINCT DEVEUI
FROM osmdb.t_osm_order_dev
WHERE ORDNO = #{p.ordNo, jdbcType=VARCHAR})
</if>
<if test='p.devStatus != -1 and p.devStatus != 99 and p.devStatus != -99 '>
AND t.DEVSTATUS = #{p.devStatus, jdbcType=INTEGER}
</if>
<if test='p.devStatus == 99'>
AND t.DEVSTATUS NOT IN (20,21)
</if>
<!-- -99代表後臺重新建立發貨清單 -->
<if test='p.devStatus == -99'>
AND t.DEVSTATUS IN (11,13)
</if>
<if test='p.beginDate != null'>
AND t.OPTIME >= #{p.beginDate, jdbcType=DATE}
</if>
<if test='p.endDate != null'>
AND t.OPTIME <= #{p.endDate, jdbcType=DATE}
</if>
<if test='p.boxnoList != null and p.boxnoList.size()>0'>
AND t.BOXNO in
<foreach collection="p.boxnoList" open="(" close=")" separator="," item="boxno">
#{boxno, jdbcType=VARCHAR}
</foreach>
</if>
ORDER BY t.DEVEUI
LIMIT #{p.batch, jdbcType=INTEGER} OFFSET #{p.offset, jdbcType=INTEGER}
</select>
相關文章
- mybatis 根據多個id查詢資料 foreach標籤MyBatis
- MyBatis從入門到精通(十二):使用collection標籤實現巢狀查詢MyBatis巢狀
- MyBatis從入門到精通(十):使用association標籤實現巢狀查詢MyBatis巢狀
- Mybatis查詢MyBatis
- Linux裝置名稱的查詢Linux
- Mybatis中常用的標籤MyBatis
- mybatis lambdaQuery 查詢條件導致空指標MyBatis指標
- 流式查詢1. mybatis的遊標Cursor,分頁大資料查詢MyBatis大資料
- [Golang實戰] 查詢docker search name的映象標籤GolangDocker
- Elasticsearch 按照標籤匹配個數優先排序查詢Elasticsearch排序
- WEB端:裝置標識號如何識別?Web
- Linux 裝置檔案/dev/*詳解、查詢Linuxdev
- 二、mybatis查詢分析MyBatis
- MyBatis模糊查詢LIKEMyBatis
- Mybatis延遲查詢MyBatis
- MyBatis帶參查詢MyBatis
- mybatis - [07] 模糊查詢MyBatis
- Mybatis簡單查詢MyBatis
- 查詢手機號碼是否支援攜號轉網的API介面API
- IndexedDB 程式碼封裝、效能摸索以及多標籤支援Index封裝
- Mybatis的 foreach 標籤使用方法.MyBatis
- mybatis的 choose -- when test -- otherwise 標籤和 if test 標籤的區別MyBatis
- mybatis like 查詢的例子MyBatis
- mybatis-plus 使用In查詢MyBatis
- 遊標查詢
- mybatis中 if 標籤 test 等於判斷MyBatis
- MyBatis if 標籤的坑,居然被我踩到了。。。MyBatis
- Android與物聯網裝置通訊-利用UDP廣播來做裝置查詢AndroidUDP
- 查詢 - 符號表符號
- 查詢SQLSERVER版本號SQLServer
- 如何在SpringBoot/Tomcat的URL查詢字串中的支援括號?Spring BootTomcat字串
- MSE標籤路由支援JDK 11嗎?路由JDK
- mybatis-模糊查詢like CONCATMyBatis
- MyBatis使用四(查詢詳解)MyBatis
- 【mybatis-plus】條件查詢MyBatis
- Mybatis學習01:利用mybatis查詢資料庫MyBatis資料庫
- 如何查詢上標
- MYSQL學習筆記25: 多表查詢(子查詢)[標量子查詢,列子查詢]MySql筆記