DeviceDefendServiceImpl.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.xcgl.device.service.impl;
  2. import cn.com.lzt.common.util.StringUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.daju.common.util.DataPage;
  7. import com.daju.mix.dao.entity.PDeviceDefend;
  8. import com.daju.mix.dao.mapper.PDeviceDefendMapper;
  9. import com.daju.mix.dao.service.impl.BaseServiceImpl;
  10. import com.xcgl.device.service.DeviceDefendService;
  11. import org.springframework.stereotype.Service;
  12. import java.util.Map;
  13. /**
  14. *
  15. * @author :sahib.kio.m
  16. * @date :Created in 2021/7/30 上午11:43
  17. */
  18. @Service
  19. public class DeviceDefendServiceImpl extends BaseServiceImpl<PDeviceDefendMapper, PDeviceDefend> implements DeviceDefendService {
  20. public DataPage DefendList(Map<String, String> param) {
  21. DataPage result = new DataPage();
  22. int page = 1;
  23. if(param.containsKey("page")){
  24. page = Integer.valueOf(param.get("page"));
  25. }
  26. int rows = 999;
  27. if(param.containsKey("rows")){
  28. rows = Integer.valueOf(param.get("rows"));
  29. }
  30. String code = param.get("code");
  31. String deviceCode = param.get("device.code");
  32. String typeId = param.get("type.id");
  33. String type = param.get("type");
  34. String date = param.get("defend.date");
  35. QueryWrapper<?> queryWrapper = new QueryWrapper<>();
  36. 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 " +
  37. "FROM p_device_defend tbcd\n" +
  38. "LEFT JOIN p_device PD ON tbcd.device_code = PD.code where 1 = 1\n";
  39. if(!StringUtil.isEmpty(code)){
  40. selectSql += "and tbcd.code like '%" + code + "%'";
  41. }
  42. if(!StringUtil.isEmpty(deviceCode)){
  43. selectSql += "and pd.code = '" + deviceCode + "'";
  44. }
  45. if(!StringUtil.isEmpty(typeId)){
  46. selectSql += "and pd.type_id = '" + typeId + "'";
  47. }
  48. if(!StringUtil.isEmpty(type)){
  49. selectSql += "and tbcd.type = '" + type + "'";
  50. }
  51. if(!StringUtil.isEmpty(date)){
  52. selectSql += "and tbcd.defend_date = '" + date + "'";
  53. }
  54. IPage<Map<String, Object>> mapPage = getBaseMapper().queryMapPageBySql(new Page<>(page, rows), queryWrapper, selectSql);
  55. result.setList(mapPage.getRecords());
  56. result.setTotalCount((int) mapPage.getTotal());
  57. return result;
  58. }
  59. }