| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.xcgl.device.service.impl;
- import cn.com.lzt.common.util.StringUtil;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.daju.common.util.DataPage;
- import com.daju.mix.dao.entity.PDeviceDefend;
- import com.daju.mix.dao.mapper.PDeviceDefendMapper;
- import com.daju.mix.dao.service.impl.BaseServiceImpl;
- import com.xcgl.device.service.DeviceDefendService;
- import org.springframework.stereotype.Service;
- import java.util.Map;
- /**
- *
- * @author :sahib.kio.m
- * @date :Created in 2021/7/30 上午11:43
- */
- @Service
- public class DeviceDefendServiceImpl extends BaseServiceImpl<PDeviceDefendMapper, PDeviceDefend> implements DeviceDefendService {
- public DataPage DefendList(Map<String, String> param) {
- DataPage result = new DataPage();
- int page = 1;
- if(param.containsKey("page")){
- page = Integer.valueOf(param.get("page"));
- }
- int rows = 999;
- if(param.containsKey("rows")){
- rows = Integer.valueOf(param.get("rows"));
- }
- String code = param.get("code");
- String deviceCode = param.get("device.code");
- String typeId = param.get("type.id");
- String type = param.get("type");
- String date = param.get("defend.date");
- QueryWrapper<?> queryWrapper = new QueryWrapper<>();
- String selectSql = " SELECT tbcd.*, PD.type_id,date_format(DATE_ADD(STR_TO_DATE(tbcd.defend_date, '%Y-%m-%d'), INTERVAL tbcd.defend_split DAY), '%Y-%m-%d') as next_day " +
- "FROM p_device_defend tbcd\n" +
- "LEFT JOIN p_device PD ON tbcd.device_code = PD.code where 1 = 1\n";
- if(!StringUtil.isEmpty(code)){
- selectSql += "and tbcd.code like '%" + code + "%'";
- }
- if(!StringUtil.isEmpty(deviceCode)){
- selectSql += "and pd.code = '" + deviceCode + "'";
- }
- if(!StringUtil.isEmpty(typeId)){
- selectSql += "and pd.type_id = '" + typeId + "'";
- }
- if(!StringUtil.isEmpty(type)){
- selectSql += "and tbcd.type = '" + type + "'";
- }
- if(!StringUtil.isEmpty(date)){
- selectSql += "and tbcd.defend_date = '" + date + "'";
- }
- IPage<Map<String, Object>> mapPage = getBaseMapper().queryMapPageBySql(new Page<>(page, rows), queryWrapper, selectSql);
- result.setList(mapPage.getRecords());
- result.setTotalCount((int) mapPage.getTotal());
- return result;
- }
- }
|