DatacollectLogDao.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.yihu.hos.datacollect.dao;
  2. import com.yihu.hos.datacollect.model.RsDatapushLog;
  3. import com.yihu.hos.web.framework.constant.DateConvert;
  4. import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
  5. import com.yihu.hos.web.framework.model.DataGridResult;
  6. import org.springframework.stereotype.Repository;
  7. import org.springframework.util.StringUtils;
  8. import java.util.Date;
  9. import java.util.GregorianCalendar;
  10. import java.util.Map;
  11. /**
  12. * Created by hzp on 2016/1/11.
  13. */
  14. @Repository("DatacollectLogDao")
  15. public class DatacollectLogDao extends SQLGeneralDAO {
  16. public static final String BEAN_ID = "DatacollectLogDao";
  17. /**
  18. * 修改轮询字段
  19. */
  20. public void updateJobDatasetKeyvalue(String id,String jobDatasetKeyvalue) throws Exception
  21. {
  22. String sql = "update rs_job_dataset set job_dataset_keyvalue='"+jobDatasetKeyvalue+"' where id='"+id+"'";
  23. super.execute(sql);
  24. }
  25. /******************************** 推模式日志 ***************************************/
  26. /**
  27. * 推数据新增日志
  28. */
  29. public void addDataPushLog(String type,String success,String content) throws Exception
  30. {
  31. RsDatapushLog log = new RsDatapushLog();
  32. log.setType(type);
  33. log.setSuccess(success);
  34. log.setContent(content);
  35. log.setDatetime(new Date());
  36. this.saveEntity(log);
  37. }
  38. /**
  39. * 获取日志列表
  40. */
  41. public DataGridResult queryDataPushLog(Map<String, Object> conditionMap, Integer page, Integer pageSize) throws Exception
  42. {
  43. StringBuilder sb = new StringBuilder();
  44. sb.append("from RsDatapushLog where 1=1 ");
  45. if (!StringUtils.isEmpty(conditionMap.get("type"))) {
  46. sb.append(" and type ='"+conditionMap.get("type")+"'");
  47. }
  48. if (!StringUtils.isEmpty(conditionMap.get("datetimeFrom"))) {
  49. Date time = DateConvert.toDate(conditionMap.get("datetimeFrom").toString());
  50. time.setHours(0);
  51. time.setMinutes(0);
  52. time.setSeconds(0);
  53. sb.append(" and datetime >= '"+DateConvert.toString(time)+"'");
  54. }
  55. if (!StringUtils.isEmpty(conditionMap.get("datetimeTo"))) {
  56. Date time = DateConvert.toDate(conditionMap.get("datetimeTo").toString());
  57. time.setHours(0);
  58. time.setMinutes(0);
  59. time.setSeconds(0);
  60. GregorianCalendar gc=new GregorianCalendar();
  61. gc.setTime(time);
  62. gc.add(5, 1);
  63. sb.append(" and datetime < '"+DateConvert.toString(gc.getTime())+"'");
  64. }
  65. sb.append("order by datetime desc");
  66. return getDataGridResult(sb.toString(),page,pageSize);
  67. }
  68. }