diff --git a/src/main/java/com/jdc/jdcproject/controller/FangpaishuiPumpoperationrecordController.java b/src/main/java/com/jdc/jdcproject/controller/FangpaishuiPumpoperationrecordController.java new file mode 100644 index 0000000..0a93f66 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/controller/FangpaishuiPumpoperationrecordController.java @@ -0,0 +1,81 @@ +package com.jdc.jdcproject.controller; + +import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord; +import com.jdc.jdcproject.entity.FangpaishuiUnit; +import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo; +import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo; +import com.jdc.jdcproject.service.EquipmentService; +import com.jdc.jdcproject.service.FangpaishuiPumpoperationrecordService; +import com.jdc.jdcproject.utils.Result; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; +import java.util.List; + +@RestController +@RequestMapping("/FangpaishuiPumpoperationrecordController") +public class FangpaishuiPumpoperationrecordController { + @Autowired + private FangpaishuiPumpoperationrecordService fangpaishuiPumpoperationrecordService; + + @Operation(summary = "根据条件查询水泵运行日志") + @PostMapping("findPumpoperationrecordByDetail") + public Result findPumpoperationrecordByDetail(@RequestBody FangpaishuiPumpoperationrecordVo fangpaishuiPumpoperationrecordVo) { + List vos = fangpaishuiPumpoperationrecordService.findDetail(fangpaishuiPumpoperationrecordVo); + return Result.successResult().data("vos", vos); + } + @Operation(summary = "新增水泵运行日志") + @PostMapping("addFangpaishuiPumpoperationrecord") + public Result addFangpaishuiPumpoperationrecord(@RequestBody FangpaishuiPumpoperationrecord fangpaishuiPumpoperationrecord) { + Date date = new Date(); + Instant instant = date.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDate localDate = instant.atZone(zoneId).toLocalDate(); + fangpaishuiPumpoperationrecord.setMonth(localDate); + //计算小时差并写入操作时间 + Long start = fangpaishuiPumpoperationrecord.getStartupTime().getTime(); + Long end = fangpaishuiPumpoperationrecord.getEndTime().getTime(); + int minutes = (int) ((end - start) / (1000 * 60)); + fangpaishuiPumpoperationrecord.setOperationTime((double) (minutes/60)); + System.out.println(fangpaishuiPumpoperationrecord); + + boolean updateflag = fangpaishuiPumpoperationrecordService.save(fangpaishuiPumpoperationrecord); + if (updateflag) { + return Result.successResult(); + } else { + return Result.errorResult(); + } + } + + @Operation(summary = "删除水泵运行日志") + @DeleteMapping("deleteFangpaishuiPumpoperationrecord/{id}") + public Result deleteFangpaishuiPumpoperationrecord(@PathVariable int id) { + boolean updateflag = fangpaishuiPumpoperationrecordService.removeById(id); + if (updateflag) { + return Result.successResult(); + } else { + return Result.errorResult(); + } + } + + @Operation(summary = "修改水泵运行日志") + @PostMapping("updateFangpaishuiPumpoperationrecord") + public Result updateFangpaishuiPumpoperationrecord(@RequestBody FangpaishuiPumpoperationrecord fangpaishuiPumpoperationrecord) { + //计算小时差并写入操作时间 + Long start = fangpaishuiPumpoperationrecord.getStartupTime().getTime(); + Long end = fangpaishuiPumpoperationrecord.getEndTime().getTime(); + int minutes = (int) ((end - start) / (1000 * 60)); + fangpaishuiPumpoperationrecord.setOperationTime((double) (minutes/60)); + boolean updateflag = fangpaishuiPumpoperationrecordService.updateById(fangpaishuiPumpoperationrecord); + if (updateflag) { + return Result.successResult(); + } else { + return Result.errorResult(); + } + } +} diff --git a/src/main/java/com/jdc/jdcproject/entity/FangpaishuiPumpoperationrecord.java b/src/main/java/com/jdc/jdcproject/entity/FangpaishuiPumpoperationrecord.java new file mode 100644 index 0000000..5deb8ee --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/entity/FangpaishuiPumpoperationrecord.java @@ -0,0 +1,135 @@ +package com.jdc.jdcproject.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDate; +import java.util.Date; + +import lombok.Data; + +/** + * 泵站操作记录表; + * @TableName fangpaishui_pumpoperationrecord + */ +@TableName(value ="fangpaishui_pumpoperationrecord") +@Data +public class FangpaishuiPumpoperationrecord implements Serializable { + /** + * 主键,唯一标识操作记录 + */ + @TableId(value = "RecordID") + private Integer recordID; + + /** + * 外键,关联操作的机组 + */ + @TableField(value = "UnitID") + private Integer unitID; + + /** + * 操作类型(“排水”或“倒水”) + */ + @TableField(value = "OperationType") + private String operationType; + + /** + * 操作时间(小时) + */ + @TableField(value = "OperationTime") + private Double operationTime; + + /** + * 排水量/倒水量(单位:立方米) + */ + @TableField(value = "Volume") + private Integer volume; + + /** + * 月份(格式:YYYY-MM-dd) + */ + @TableField(value = "Month") + private LocalDate month; + + /** + * 班次(白班、零点班、四点班) + */ + @TableField(value = "Sailings") + private String sailings; + + /** + * 启动时间(格式:YYYY-MM-dd HH:mm:ss) + */ + @TableField(value = "StartupTime") + private Date startupTime; + + /** + * 停止时间(格式:YYYY-MM-dd HH:mm:ss) + */ + @TableField(value = "EndTime") + private Date endTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + FangpaishuiPumpoperationrecord other = (FangpaishuiPumpoperationrecord) that; + return (this.getRecordID() == null ? other.getRecordID() == null : this.getRecordID().equals(other.getRecordID())) + && (this.getUnitID() == null ? other.getUnitID() == null : this.getUnitID().equals(other.getUnitID())) + && (this.getOperationType() == null ? other.getOperationType() == null : this.getOperationType().equals(other.getOperationType())) + && (this.getOperationTime() == null ? other.getOperationTime() == null : this.getOperationTime().equals(other.getOperationTime())) + && (this.getVolume() == null ? other.getVolume() == null : this.getVolume().equals(other.getVolume())) + && (this.getMonth() == null ? other.getMonth() == null : this.getMonth().equals(other.getMonth())) + && (this.getSailings() == null ? other.getSailings() == null : this.getSailings().equals(other.getSailings())) + && (this.getStartupTime() == null ? other.getStartupTime() == null : this.getStartupTime().equals(other.getStartupTime())) + && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getRecordID() == null) ? 0 : getRecordID().hashCode()); + result = prime * result + ((getUnitID() == null) ? 0 : getUnitID().hashCode()); + result = prime * result + ((getOperationType() == null) ? 0 : getOperationType().hashCode()); + result = prime * result + ((getOperationTime() == null) ? 0 : getOperationTime().hashCode()); + result = prime * result + ((getVolume() == null) ? 0 : getVolume().hashCode()); + result = prime * result + ((getMonth() == null) ? 0 : getMonth().hashCode()); + result = prime * result + ((getSailings() == null) ? 0 : getSailings().hashCode()); + result = prime * result + ((getStartupTime() == null) ? 0 : getStartupTime().hashCode()); + result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", recordID=").append(recordID); + sb.append(", unitID=").append(unitID); + sb.append(", operationType=").append(operationType); + sb.append(", operationTime=").append(operationTime); + sb.append(", volume=").append(volume); + sb.append(", month=").append(month); + sb.append(", sailings=").append(sailings); + sb.append(", startupTime=").append(startupTime); + sb.append(", endTime=").append(endTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/jdc/jdcproject/entity/VO/FangpaishuiPumpoperationrecordVo.java b/src/main/java/com/jdc/jdcproject/entity/VO/FangpaishuiPumpoperationrecordVo.java new file mode 100644 index 0000000..981e321 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/entity/VO/FangpaishuiPumpoperationrecordVo.java @@ -0,0 +1,160 @@ +package com.jdc.jdcproject.entity.VO; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.Date; + +/** + * 泵站操作VO + */ +@Data +public class FangpaishuiPumpoperationrecordVo implements Serializable { + /** + * 主键,唯一标识操作记录 + */ + @TableId(value = "RecordID") + @Schema(description = "主键") + private Integer recordID; + + /** + * 外键,关联操作的设备 + */ + @Schema(description = "设备ID") + private Integer EquipmentId; + + /** + * 外键,关联操作的机组 + */ + @Schema(description = "机组编码") + private String unitCode; + + /** + * 外键,关联操作的设备 + */ + @Schema(description = "设备名称") + private String EquipmentName; + + /** + * 外键,关联操作的机组 + */ + @Schema(description = "机组ID") + private Integer unitID; + + /** + * 额定排水量(固定属性) + */ + @Schema(description = "额定排水量") + private Integer ratedCapacity; + + /** + * 班次(白班、零点班、四点班) + */ + @Schema(description = "班次") + private String sailings; + + /** + * 操作类型(“排水”或“倒水”) + */ + @Schema(description = "操作类型") + private String operationType; + + /** + * 操作时间(小时) + */ + @Schema(description = "操作时间(小时)") + private Double operationTime; + + /** + * 排水量/倒水量(单位:立方米) + */ + @Schema(description = "排水量/倒水量(单位:立方米)") + private Integer volume; + + /** + * 日期(格式:YYYY-MM-dd ) + */ + @Schema(description = "日期") + private LocalDate month; + + + + /** + * 启动时间(格式:YYYY-MM-dd HH:mm:ss ) + */ + @Schema(description = "启动时间") + private Date startupTime; + + /** + * 停止时间(格式:YYYY-MM-dd HH:mm:ss ) + */ + @Schema(description = "停止时间") + private Date endTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + FangpaishuiPumpoperationrecordVo other = (FangpaishuiPumpoperationrecordVo) that; + return (this.getRecordID() == null ? other.getRecordID() == null : this.getRecordID().equals(other.getRecordID())) + && (this.getUnitID() == null ? other.getUnitID() == null : this.getUnitID().equals(other.getUnitID())) + && (this.getOperationType() == null ? other.getOperationType() == null : this.getOperationType().equals(other.getOperationType())) + && (this.getOperationTime() == null ? other.getOperationTime() == null : this.getOperationTime().equals(other.getOperationTime())) + && (this.getVolume() == null ? other.getVolume() == null : this.getVolume().equals(other.getVolume())) + && (this.getMonth() == null ? other.getMonth() == null : this.getMonth().equals(other.getMonth())) + && (this.getSailings() == null ? other.getSailings() == null : this.getSailings().equals(other.getSailings())) + && (this.getStartupTime() == null ? other.getStartupTime() == null : this.getStartupTime().equals(other.getStartupTime())) + && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getRecordID() == null) ? 0 : getRecordID().hashCode()); + result = prime * result + ((getUnitID() == null) ? 0 : getUnitID().hashCode()); + result = prime * result + ((getOperationType() == null) ? 0 : getOperationType().hashCode()); + result = prime * result + ((getOperationTime() == null) ? 0 : getOperationTime().hashCode()); + result = prime * result + ((getVolume() == null) ? 0 : getVolume().hashCode()); + result = prime * result + ((getMonth() == null) ? 0 : getMonth().hashCode()); + result = prime * result + ((getSailings() == null) ? 0 : getSailings().hashCode()); + result = prime * result + ((getStartupTime() == null) ? 0 : getStartupTime().hashCode()); + result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", recordID=").append(recordID); + sb.append(", unitID=").append(unitID); + sb.append(", operationType=").append(operationType); + sb.append(", operationTime=").append(operationTime); + sb.append(", volume=").append(volume); + sb.append(", month=").append(month); + sb.append(", sailings=").append(sailings); + sb.append(", startupTime=").append(startupTime); + sb.append(", endTime=").append(endTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/jdc/jdcproject/mapper/FangpaishuiPumpoperationrecordMapper.java b/src/main/java/com/jdc/jdcproject/mapper/FangpaishuiPumpoperationrecordMapper.java new file mode 100644 index 0000000..ebab766 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/mapper/FangpaishuiPumpoperationrecordMapper.java @@ -0,0 +1,23 @@ +package com.jdc.jdcproject.mapper; + +import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo; +import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo; + +import java.util.List; + +/** +* @author 95262 +* @description 针对表【fangpaishui_pumpoperationrecord(泵站操作记录表;)】的数据库操作Mapper +* @createDate 2025-05-07 13:37:49 +* @Entity com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord +*/ +public interface FangpaishuiPumpoperationrecordMapper extends BaseMapper { + + List findDetail(FangpaishuiPumpoperationrecordVo vo); +} + + + + diff --git a/src/main/java/com/jdc/jdcproject/mapper/xml/FangpaishuiPumpoperationrecordMapper.xml b/src/main/java/com/jdc/jdcproject/mapper/xml/FangpaishuiPumpoperationrecordMapper.xml new file mode 100644 index 0000000..a012bc2 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/mapper/xml/FangpaishuiPumpoperationrecordMapper.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/src/main/java/com/jdc/jdcproject/service/FangpaishuiPumpoperationrecordService.java b/src/main/java/com/jdc/jdcproject/service/FangpaishuiPumpoperationrecordService.java new file mode 100644 index 0000000..d5e3392 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/service/FangpaishuiPumpoperationrecordService.java @@ -0,0 +1,17 @@ +package com.jdc.jdcproject.service; + +import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord; +import com.baomidou.mybatisplus.extension.service.IService; +import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo; +import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo; + +import java.util.List; + +/** +* @author 95262 +* @description 针对表【fangpaishui_pumpoperationrecord(泵站操作记录表;)】的数据库操作Service +* @createDate 2025-05-07 13:37:49 +*/ +public interface FangpaishuiPumpoperationrecordService extends IService { + List findDetail(FangpaishuiPumpoperationrecordVo vo); +} diff --git a/src/main/java/com/jdc/jdcproject/service/impl/FangpaishuiPumpoperationrecordServiceImpl.java b/src/main/java/com/jdc/jdcproject/service/impl/FangpaishuiPumpoperationrecordServiceImpl.java new file mode 100644 index 0000000..1ad48d0 --- /dev/null +++ b/src/main/java/com/jdc/jdcproject/service/impl/FangpaishuiPumpoperationrecordServiceImpl.java @@ -0,0 +1,29 @@ +package com.jdc.jdcproject.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord; +import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo; +import com.jdc.jdcproject.service.FangpaishuiPumpoperationrecordService; +import com.jdc.jdcproject.mapper.FangpaishuiPumpoperationrecordMapper; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* @author 95262 +* @description 针对表【fangpaishui_pumpoperationrecord(泵站操作记录表;)】的数据库操作Service实现 +* @createDate 2025-05-07 13:37:49 +*/ +@Service +public class FangpaishuiPumpoperationrecordServiceImpl extends ServiceImpl + implements FangpaishuiPumpoperationrecordService{ + + @Override + public List findDetail(FangpaishuiPumpoperationrecordVo vo) { + return baseMapper.findDetail(vo); + } +} + + + +