parent
bf530e253d
commit
cebcfb50f4
13 changed files with 788 additions and 36 deletions
@ -0,0 +1,40 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.mapper; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerReportFormsEntity; |
||||
|
||||
/** |
||||
* 酸雾塔报表统计表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
public interface EpTowerReportFormsMapper extends BaseMapper<EpTowerReportFormsEntity> { |
||||
|
||||
} |
||||
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.desk.energy.mapper.EpTowerReportFormsMapper"> |
||||
</mapper> |
||||
@ -0,0 +1,40 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.mapper; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerRunTimeEntity; |
||||
|
||||
/** |
||||
* 酸雾塔运行时间表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
public interface EpTowerRunTimeMapper extends BaseMapper<EpTowerRunTimeEntity> { |
||||
|
||||
} |
||||
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.desk.energy.mapper.EpTowerRunTimeMapper"> |
||||
|
||||
</mapper> |
||||
@ -0,0 +1,104 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.io.Serial; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 酸雾塔报表统计表 实体类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
@Data |
||||
@TableName("EP_TOWER_REPORT_FORMS") |
||||
@Schema(description = "EpTowerReportForms对象") |
||||
public class EpTowerReportFormsEntity { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 酸雾塔 |
||||
*/ |
||||
@TableId |
||||
@Schema(description = "酸雾塔") |
||||
private Long btId; |
||||
/** |
||||
* 点位 |
||||
*/ |
||||
@Schema(description = "点位") |
||||
private String key; |
||||
/** |
||||
* 类型;1、PH,2、风机,3、循环泵 |
||||
*/ |
||||
@Schema(description = "类型;1、PH,2、风机,3、循环泵") |
||||
private Integer etrType; |
||||
/** |
||||
* 开始时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@Schema(description = "开始时间") |
||||
private Date startTime; |
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@Schema(description = "结束时间") |
||||
private Date endTime; |
||||
/** |
||||
* 时间 |
||||
*/ |
||||
@Schema(description = "时间") |
||||
private BigDecimal etrTime; |
||||
/** |
||||
* PH |
||||
*/ |
||||
public static Short PH = 1; |
||||
/** |
||||
* 风机 |
||||
*/ |
||||
public static Short FAN = 2; |
||||
/** |
||||
* 循环泵 |
||||
*/ |
||||
public static Short PUMP = 3; |
||||
} |
||||
@ -0,0 +1,87 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.io.Serial; |
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 酸雾塔运行时间表 实体类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
@Data |
||||
@TableName("EP_TOWER_RUN_TIME") |
||||
@Schema(description = "EpTowerRunTime对象") |
||||
public class EpTowerRunTimeEntity implements Serializable { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 流水号 |
||||
*/ |
||||
@TableId |
||||
@Schema(description = "流水号") |
||||
private Long etrtId; |
||||
/** |
||||
* 酸雾塔 |
||||
*/ |
||||
@Schema(description = "酸雾塔") |
||||
private Long btId; |
||||
/** |
||||
* 开始时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@Schema(description = "开始时间") |
||||
private Date startTime; |
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
||||
@Schema(description = "结束时间") |
||||
private Date endTime; |
||||
/** |
||||
* 时间 |
||||
*/ |
||||
@Schema(description = "时间") |
||||
private BigDecimal etrtTime; |
||||
|
||||
} |
||||
@ -0,0 +1,41 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerReportFormsEntity; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 酸雾塔报表统计表 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
public interface IEpTowerReportFormsService extends IService<EpTowerReportFormsEntity> { |
||||
EpTowerReportFormsEntity getTowerReportByTerm(String pid, Short type, Long id); |
||||
} |
||||
@ -0,0 +1,40 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerRunTimeEntity; |
||||
|
||||
/** |
||||
* 酸雾塔运行时间表 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
public interface IEpTowerRunTimeService extends IService<EpTowerRunTimeEntity> { |
||||
|
||||
EpTowerRunTimeEntity getEpTowerRunTimeByBtId(Long id); |
||||
} |
||||
@ -0,0 +1,61 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.service.impl; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.apache.commons.io.filefilter.FalseFileFilter; |
||||
import org.springblade.desk.energy.mapper.EpTowerReportFormsMapper; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerReportFormsEntity; |
||||
import org.springblade.desk.energy.service.IEpTowerReportFormsService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 酸雾塔报表统计表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
@Service |
||||
public class EpTowerReportFormsServiceImpl extends ServiceImpl<EpTowerReportFormsMapper, EpTowerReportFormsEntity> implements IEpTowerReportFormsService { |
||||
|
||||
@Override |
||||
public EpTowerReportFormsEntity getTowerReportByTerm(String pid, Short type, Long id) { |
||||
//String sql = " select a.* from ep_tower_report a where a.key=:key and a.etr_type=:type and a.bt_id = :btId and a.end_time is null";
|
||||
//Query<EpTowerReport> query = this.getSession().createSQLQuery(sql).addEntity(EpTowerReport.class);
|
||||
//query.setParameter("key", key);
|
||||
//query.setParameter("type", type);
|
||||
//query.setParameter("btId", btId);
|
||||
//return query.uniqueResult();
|
||||
return getOne(Wrappers.lambdaQuery(EpTowerReportFormsEntity.class) |
||||
.eq(EpTowerReportFormsEntity::getKey, pid) |
||||
.eq(EpTowerReportFormsEntity::getEtrType, type) |
||||
.eq(EpTowerReportFormsEntity::getBtId, id),false); |
||||
} |
||||
} |
||||
@ -0,0 +1,56 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.energy.service.impl; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springblade.desk.energy.mapper.EpTowerRunTimeMapper; |
||||
import org.springblade.desk.energy.pojo.entity.EpTowerRunTimeEntity; |
||||
import org.springblade.desk.energy.service.IEpTowerRunTimeService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 酸雾塔运行时间表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-04-24 |
||||
*/ |
||||
@Service |
||||
public class EpTowerRunTimeServiceImpl extends ServiceImpl<EpTowerRunTimeMapper, EpTowerRunTimeEntity> implements IEpTowerRunTimeService { |
||||
|
||||
@Override |
||||
public EpTowerRunTimeEntity getEpTowerRunTimeByBtId(Long id) { |
||||
// String sql = " select a.* from ep_tower_run_time a where a.bt_id = :btId and a.end_time is null";
|
||||
// Query<EpTowerRunTime> query = this.getSession().createSQLQuery(sql).addEntity(EpTowerRunTime.class);
|
||||
// query.setParameter("btId", btId);
|
||||
// return query.uniqueResult();
|
||||
|
||||
return getOne(Wrappers.lambdaQuery(EpTowerRunTimeEntity.class) |
||||
.eq(EpTowerRunTimeEntity::getBtId, id) |
||||
.isNull(EpTowerRunTimeEntity::getEndTime)); |
||||
} |
||||
} |
||||
@ -0,0 +1,237 @@ |
||||
package org.springblade.desk.energy.util;/** |
||||
* @date : 2026/4/24 13:18 |
||||
*/ |
||||
|
||||
/** |
||||
* 文件名称 |
||||
* @module 归属项目 |
||||
* @author *** |
||||
* @date 2025/11/26 10:27 |
||||
*/ |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import java.time.ZoneId; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
|
||||
public final class DateTime implements Serializable { |
||||
private static final long serialVersionUID = -1435674106176979553L; |
||||
private Date _date; |
||||
private Calendar cal; |
||||
private static DateTimeFormatter defaultDateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
||||
|
||||
public DateTime(Date d) { |
||||
this._date = null; |
||||
this.cal = Calendar.getInstance(); |
||||
this._date = d; |
||||
this.cal.setTime(this._date); |
||||
} |
||||
|
||||
public DateTime(String dstr) { |
||||
this(parse(dstr)); |
||||
} |
||||
|
||||
public Date getDate() { |
||||
return this._date; |
||||
} |
||||
|
||||
public TimeSpan subtract(DateTime dt) { |
||||
return dateDiff(this._date, dt.getDate()); |
||||
} |
||||
|
||||
public DateTime subtract(TimeSpan ts) { |
||||
TimeSpan nts = new TimeSpan(-ts.getTotalMilliseconds()); |
||||
return new DateTime(dateAdd(this._date, nts)); |
||||
} |
||||
|
||||
public static DateTime now() { |
||||
return new DateTime(new Date()); |
||||
} |
||||
|
||||
public static Date parse(String d) { |
||||
if (d != null && d.trim().length() != 0) { |
||||
if (d.length() < 19) { |
||||
d = d + "0000-00-00 00:00:00".substring(d.length()); |
||||
} |
||||
|
||||
return Date.from(LocalDateTime.parse(d, defaultDateTimeFormat).atZone(ZoneId.systemDefault()).toInstant()); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public static final Date getDateWithoutTime(Date d) { |
||||
if (d == null) { |
||||
return null; |
||||
} else { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.set(11, 0); |
||||
c.set(12, 0); |
||||
c.set(13, 0); |
||||
c.set(14, 0); |
||||
return c.getTime(); |
||||
} |
||||
} |
||||
|
||||
public static final Date getDateWithMaxTime(Date d) { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.set(11, 23); |
||||
c.set(12, 59); |
||||
c.set(13, 59); |
||||
c.set(14, 999); |
||||
return c.getTime(); |
||||
} |
||||
|
||||
public static final Date getDateWithMaxTime(Date d, int millisecond) { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.set(11, 23); |
||||
c.set(12, 59); |
||||
c.set(13, 59); |
||||
c.set(14, millisecond); |
||||
return c.getTime(); |
||||
} |
||||
|
||||
public static final Date getFirstDayOfMonth(Date d) { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.set(5, 1); |
||||
c.set(11, 0); |
||||
c.set(12, 0); |
||||
c.set(13, 0); |
||||
c.set(14, 0); |
||||
return c.getTime(); |
||||
} |
||||
|
||||
public static final Date getFirstDayOfMonth() { |
||||
Date d = new Date(); |
||||
return getFirstDayOfMonth(d); |
||||
} |
||||
|
||||
public static final Date getLastDayOfMonth(Date d) { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.add(2, 1); |
||||
c.set(5, 1); |
||||
c.add(5, -1); |
||||
c.set(11, 0); |
||||
c.set(12, 0); |
||||
c.set(13, 0); |
||||
c.set(14, 0); |
||||
return c.getTime(); |
||||
} |
||||
|
||||
public static final Date getLastDayOfMonth() { |
||||
Date d = new Date(); |
||||
return getLastDayOfMonth(d); |
||||
} |
||||
|
||||
public static String getToday() { |
||||
return date2String(new Date()); |
||||
} |
||||
|
||||
public static final String getTimeNow() { |
||||
return date2String(new Date(), true, true); |
||||
} |
||||
|
||||
public static String date2String(Date d) { |
||||
return date2String(d, false, false, (String)null); |
||||
} |
||||
|
||||
public static final String date2String(Date d, boolean withTime, boolean withSecond) { |
||||
return date2String(d, withTime, withSecond, (String)null); |
||||
} |
||||
|
||||
public static final String date2String(Date d, boolean withTime, boolean withSecond, String dateSplitChar) { |
||||
if (dateSplitChar == null) { |
||||
dateSplitChar = "-"; |
||||
} |
||||
|
||||
if (!withTime) { |
||||
withSecond = false; |
||||
} |
||||
|
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
int YY = c.get(1); |
||||
int MM = c.get(2) + 1; |
||||
int DD = c.get(5); |
||||
int hh = c.get(11); |
||||
int mm = c.get(12); |
||||
int ss = c.get(13); |
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append(YY).append(dateSplitChar); |
||||
sb.append(MM < 10 ? "0" : "").append(MM).append(dateSplitChar); |
||||
sb.append(DD < 10 ? "0" : "").append(DD); |
||||
if (withTime) { |
||||
sb.append(" ").append(hh < 10 ? "0" : "").append(hh); |
||||
sb.append(":").append(mm < 10 ? "0" : "").append(mm); |
||||
if (withSecond) { |
||||
sb.append(":").append(ss < 10 ? "0" : "").append(ss); |
||||
} |
||||
} |
||||
|
||||
return sb.toString(); |
||||
} |
||||
|
||||
public static final TimeSpan dateDiff(Date date1, Date date2) { |
||||
long diff = 0L; |
||||
if (date1 != null && date2 != null) { |
||||
diff = date2.getTime() - date1.getTime(); |
||||
} |
||||
|
||||
return new TimeSpan(diff); |
||||
} |
||||
|
||||
public static final Date dateAdd(Date d, TimeSpan ts) { |
||||
Calendar c = Calendar.getInstance(); |
||||
c.setTime(d); |
||||
c.add(5, ts.getDays()); |
||||
c.add(10, ts.getHours()); |
||||
c.add(12, ts.getMinutes()); |
||||
c.add(13, ts.getSeconds()); |
||||
c.add(14, ts.getMilliseconds()); |
||||
return c.getTime(); |
||||
} |
||||
|
||||
public static final long date2Long(Date d) { |
||||
return (long)date2Integer(d) * 1000000L + (long)time2Integer(d); |
||||
} |
||||
|
||||
public static final int date2Integer(Date d) { |
||||
Calendar cal = Calendar.getInstance(); |
||||
cal.setTime(d); |
||||
return cal.get(1) * 10000 + (cal.get(2) + 1) * 100 + cal.get(5); |
||||
} |
||||
|
||||
public static final int time2Integer(Date d) { |
||||
Calendar cal = Calendar.getInstance(); |
||||
cal.setTime(d); |
||||
return cal.get(11) * 10000 + cal.get(12) * 100 + cal.get(13); |
||||
} |
||||
|
||||
public static final Date integer2Date(int yyyyMMdd) { |
||||
String str = String.valueOf(yyyyMMdd); |
||||
Calendar cal = Calendar.getInstance(); |
||||
cal.set(1, Integer.parseInt(str.substring(0, 4))); |
||||
cal.set(2, Integer.parseInt(str.substring(4, 6)) - 1); |
||||
cal.set(5, Integer.parseInt(str.substring(6))); |
||||
return cal.getTime(); |
||||
} |
||||
|
||||
public Integer getYear() { |
||||
return this.cal.get(1); |
||||
} |
||||
|
||||
public Integer getMonth() { |
||||
return this.cal.get(2) + 1; |
||||
} |
||||
|
||||
public Integer getDay() { |
||||
return this.cal.get(5); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue