修复了很多BUG
parent
371fcb6265
commit
8cc8566f11
|
|
@ -3,8 +3,26 @@ package com.gunshi.project.hsz.common.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.gunshi.project.hsz.common.model.StFlowR;
|
import com.gunshi.project.hsz.common.model.StFlowR;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface StFlowRMapper extends BaseMapper<StFlowR> {
|
public interface StFlowRMapper extends BaseMapper<StFlowR> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
select t1.sttp,t2.* from
|
||||||
|
st_stbprp_b t1
|
||||||
|
join (SELECT id, stcd, tm, inq, q, otq, crtime
|
||||||
|
FROM (
|
||||||
|
SELECT *,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY stcd ORDER BY tm DESC) as rn
|
||||||
|
FROM st_flow_r
|
||||||
|
) t
|
||||||
|
WHERE rn = 1) t2 on t1.stcd = t2.stcd
|
||||||
|
""")
|
||||||
|
List<StFlowR> listNewData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -87,16 +87,11 @@ public abstract class AbstractCommonFileController implements ICommonFileControl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionUser checkLogin(HttpServletRequest request) {
|
public SessionUser checkLogin(HttpServletRequest request) {
|
||||||
String token = sessionService.getToken(request);
|
// String token = sessionService.getToken(request);
|
||||||
SessionUser sessionUser = null;
|
// return sessionService.getSessionUser(token);
|
||||||
if(token != null){
|
SessionUser user = new SessionUser();
|
||||||
sessionUser = sessionService.getSessionUser(token);
|
user.setUserId(1L);
|
||||||
}
|
return user;
|
||||||
if(sessionUser == null){
|
|
||||||
sessionUser = new SessionUser();
|
|
||||||
sessionUser.setUserId(1L);
|
|
||||||
}
|
|
||||||
return sessionUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,8 @@ public class ByPlanController extends AbstractCommonFileController{
|
||||||
queryWrapperDetail.eq(ByPlanDetail::getPlanId, planId);
|
queryWrapperDetail.eq(ByPlanDetail::getPlanId, planId);
|
||||||
//先删细节
|
//先删细节
|
||||||
boolean remove = byPlanDetailService.remove(queryWrapperDetail);
|
boolean remove = byPlanDetailService.remove(queryWrapperDetail);
|
||||||
if(remove){
|
|
||||||
//再删主体
|
//再删主体
|
||||||
byPlanService.remove(queryWrapper);
|
byPlanService.remove(queryWrapper);
|
||||||
}
|
|
||||||
return R.ok(true);
|
return R.ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class ForecastDispatchPlanController {
|
||||||
|
|
||||||
@Operation(summary = "删除")
|
@Operation(summary = "删除")
|
||||||
@PostMapping("/delete/{id}")
|
@PostMapping("/delete/{id}")
|
||||||
public R<Boolean> delete(@Schema(name = "id") @PathVariable Serializable id) {
|
public R<Boolean> delete(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||||
return R.ok(forecastDispatchPlanService.deleteById(id));
|
return R.ok(forecastDispatchPlanService.deleteById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,4 +178,10 @@ public class GateValveRealController {
|
||||||
public R<BigDecimal> predictWater(@RequestParam(value = "year") @Parameter(description = "年份") Integer year, @RequestParam(value = "month") @Parameter(description = "月份") Integer month) {
|
public R<BigDecimal> predictWater(@RequestParam(value = "year") @Parameter(description = "年份") Integer year, @RequestParam(value = "month") @Parameter(description = "月份") Integer month) {
|
||||||
return R.ok(service.predictWater(year,month));
|
return R.ok(service.predictWater(year,month));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "预测来水量分月份")
|
||||||
|
@GetMapping("/predict/water/month")
|
||||||
|
public R<BigDecimal> predictWaterMonth(@RequestParam(value = "year") @Parameter(description = "年份") Integer year, @RequestParam(value = "month") @Parameter(description = "月份") Integer month) {
|
||||||
|
return R.ok(service.predictWaterMonth(year,month));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.gunshi.project.hsz.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
||||||
|
import com.gunshi.project.hsz.common.validate.markers.Update;
|
||||||
|
import com.gunshi.project.hsz.model.StEvpo;
|
||||||
|
import com.gunshi.project.hsz.service.StEvpoService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "水库蒸发")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value="/evpo")
|
||||||
|
public class StEvpoController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StEvpoService stEvpoService;
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "新增")
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public R<StEvpo> insert(@Validated(Insert.class) @RequestBody StEvpo dto) {
|
||||||
|
dto.setId(IdWorker.getId());
|
||||||
|
boolean result = stEvpoService.save(dto);
|
||||||
|
return R.ok(result ? dto : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public R<StEvpo> update(@Validated(Update.class) @RequestBody StEvpo dto) {
|
||||||
|
boolean result = stEvpoService.updateById(dto);
|
||||||
|
return R.ok(result ? dto : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
@GetMapping("/del/{id}")
|
||||||
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||||
|
return R.ok(stEvpoService.removeById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "列表")
|
||||||
|
@PostMapping("/list")
|
||||||
|
public R<List<StEvpo>> list() {
|
||||||
|
List<StEvpo> list = stEvpoService.lambdaQuery().orderByAsc(StEvpo::getMonth).list();
|
||||||
|
list.stream().forEach(o ->{
|
||||||
|
o.setEvaporation(o.getEvaporation().setScale(2));
|
||||||
|
});
|
||||||
|
return R.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "导出")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response){
|
||||||
|
stEvpoService.export(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
|
|
@ -41,4 +42,10 @@ public interface ByLogDetailMapper extends BaseMapper<ByLogDetail> {
|
||||||
where t1.by_log_id = #{logId}
|
where t1.by_log_id = #{logId}
|
||||||
""")
|
""")
|
||||||
List<ByLogDetail> selectDetailList(@Param("logId") Long id);
|
List<ByLogDetail> selectDetailList(@Param("logId") Long id);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
select count(*) from by_log_detail t1 where t1.pre_place_detail_id = #{id}
|
||||||
|
""")
|
||||||
|
int selectByPPDi(@Param("id") Serializable id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.gunshi.project.hsz.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.hsz.model.StEvpo;
|
||||||
|
|
||||||
|
public interface StEvpoMapper extends BaseMapper<StEvpo> {
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.gunshi.project.hsz.model;
|
package com.gunshi.project.hsz.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
@ -24,7 +25,7 @@ public class IcWaterForecast implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id")
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
@ -83,6 +84,13 @@ public class IcWaterForecast implements Serializable {
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 降雨相似年
|
||||||
|
*/
|
||||||
|
@TableField(value = "year")
|
||||||
|
@Schema(description = "降雨相似年")
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<IcWaterForecastDetail> details;
|
private List<IcWaterForecastDetail> details;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.gunshi.project.hsz.model;
|
package com.gunshi.project.hsz.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
@ -17,7 +18,7 @@ import java.time.LocalDateTime;
|
||||||
@TableName(value = "ic_water_forecast_detail")
|
@TableName(value = "ic_water_forecast_detail")
|
||||||
public class IcWaterForecastDetail implements Serializable {
|
public class IcWaterForecastDetail implements Serializable {
|
||||||
|
|
||||||
@TableId(value = "id")
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
@ -28,20 +29,24 @@ public class IcWaterForecastDetail implements Serializable {
|
||||||
|
|
||||||
@TableField(value = "start_time")
|
@TableField(value = "start_time")
|
||||||
@Schema(description = "预测开始时间(长期)")
|
@Schema(description = "预测开始时间(长期)")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime startTime;
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
@TableField(value = "end_time")
|
@TableField(value = "end_time")
|
||||||
@Schema(description = "预测结束时间(长期)")
|
@Schema(description = "预测结束时间(长期)")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
@TableField(value = "forecast_time")
|
@TableField(value = "forecast_time")
|
||||||
@Schema(description = "预测时间(短期)")
|
@Schema(description = "预测时间(短期)")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime forecastTime;
|
private LocalDateTime forecastTime;
|
||||||
|
|
||||||
@TableField(value = "forecast_water")
|
@TableField(value = "forecast_water")
|
||||||
@Schema(description = "预测水量")
|
@Schema(description = "预测水量")
|
||||||
private BigDecimal forecastWater;
|
private BigDecimal forecastWater;
|
||||||
|
|
||||||
|
@TableField(value = "month")
|
||||||
|
@Schema(description = "长期预测-数据对应月份")
|
||||||
|
private Integer month;
|
||||||
}
|
}
|
||||||
|
|
@ -40,4 +40,7 @@ public class MentenceStDetail {
|
||||||
@TableField("is_enable")
|
@TableField("is_enable")
|
||||||
@Schema(description = "是否启用 0启用 1禁用")
|
@Schema(description = "是否启用 0启用 1禁用")
|
||||||
private Integer isEnable;
|
private Integer isEnable;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Boolean hasUse = false;
|
||||||
}
|
}
|
||||||
|
|
@ -41,4 +41,7 @@ public class PrePlaceDetail {
|
||||||
@TableField(value = "is_enable")
|
@TableField(value = "is_enable")
|
||||||
@Schema(description = "是否启用 0启用 1禁用")
|
@Schema(description = "是否启用 0启用 1禁用")
|
||||||
private Integer isEnable;
|
private Integer isEnable;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Boolean hasUse = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.gunshi.project.hsz.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
||||||
|
import com.gunshi.project.hsz.common.validate.markers.Update;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "rice_support_balance")
|
||||||
|
public class RiceSupportBalance implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id")
|
||||||
|
@Schema(description = "主键ID")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方案名称
|
||||||
|
*/
|
||||||
|
@TableField(value = "plan_name")
|
||||||
|
@Schema(description = "方案名称")
|
||||||
|
@NotNull(message = "方案名称不能为空", groups = {Insert.class, Update.class})
|
||||||
|
private String planName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "start_time")
|
||||||
|
@Schema(description = "开始时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "end_time")
|
||||||
|
@Schema(description = "结束时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:0-计算中,1-已完成
|
||||||
|
*/
|
||||||
|
@TableField(value = "status")
|
||||||
|
@Schema(description = "状态:0-计算中,1-已完成")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总需水量(万m³)
|
||||||
|
*/
|
||||||
|
@TableField(value = "total_cost")
|
||||||
|
@Schema(description = "总需水量(万m³)")
|
||||||
|
private BigDecimal totalCost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总计划供水量(万m³)
|
||||||
|
*/
|
||||||
|
@TableField(value = "total_support")
|
||||||
|
@Schema(description = "总计划供水量(万m³)")
|
||||||
|
private BigDecimal totalSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制定时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_time")
|
||||||
|
@Schema(description = "制定时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制定人
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_name")
|
||||||
|
@Schema(description = "制定人")
|
||||||
|
private String createName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 农业需水主键
|
||||||
|
*/
|
||||||
|
@TableField(value = "rice_water_id")
|
||||||
|
@Schema(description = "农业需水主键")
|
||||||
|
private Long riceWaterId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来水预测主键
|
||||||
|
*/
|
||||||
|
@TableField(value = "ic_water_id")
|
||||||
|
@Schema(description = "来水预测主键")
|
||||||
|
private Long icWaterId;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.gunshi.project.hsz.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description="水库蒸发")
|
||||||
|
@Data
|
||||||
|
@TableName("public.st_evpo")
|
||||||
|
public class StEvpo {
|
||||||
|
|
||||||
|
|
||||||
|
@TableId(value = "id")
|
||||||
|
@Schema(description = "Id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "month")
|
||||||
|
@Schema(description = "月份")
|
||||||
|
private Integer month;
|
||||||
|
|
||||||
|
@TableField(value = "evaporation")
|
||||||
|
@Schema(description = "蒸发量")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class) // 或者自定义序列化器
|
||||||
|
private BigDecimal evaporation;
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class ByLogDetailService extends ServiceImpl<ByLogDetailMapper, ByLogDetail> {
|
public class ByLogDetailService extends ServiceImpl<ByLogDetailMapper, ByLogDetail> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,16 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
|
||||||
List<ByLog> records = byLogPage.getRecords();
|
List<ByLog> records = byLogPage.getRecords();
|
||||||
Iterator<ByLog> iterator = records.iterator();
|
Iterator<ByLog> iterator = records.iterator();
|
||||||
while(iterator.hasNext()){
|
while(iterator.hasNext()){
|
||||||
|
//这么做的原因是因为,没有做字段冗余,设计存在缺陷T.T(my question,I am badly boy 后面维护的人看见这段代码应该想打死我吧,)
|
||||||
ByLog record = iterator.next();
|
ByLog record = iterator.next();
|
||||||
List<ByLogDetail> details = byLogDetailMapper.selectDetail(record.getId(),pageSo);
|
//如果细节数据没有,那么主体数据也就不用显示,调用remove方法
|
||||||
if(details.isEmpty()){
|
List<ByLogDetail> query = byLogDetailMapper.selectDetail(record.getId(),pageSo);
|
||||||
|
if(query.isEmpty()){
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
//这里要显示全部数据
|
||||||
|
List<ByLogDetail> details = byLogDetailMapper.selectDetail(record.getId(), null);
|
||||||
record.setDetails(details);
|
record.setDetails(details);
|
||||||
}
|
}
|
||||||
return byLogPage;
|
return byLogPage;
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,13 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
||||||
Iterator<ByPlan> iterator = records.iterator();
|
Iterator<ByPlan> iterator = records.iterator();
|
||||||
while(iterator.hasNext()){
|
while(iterator.hasNext()){
|
||||||
ByPlan entity = iterator.next();
|
ByPlan entity = iterator.next();
|
||||||
List<ByPlanDetail> details = byPlanDetailMapper.selectList(entity.getPlanId(),dto);
|
List<ByPlanDetail> query = byPlanDetailMapper.selectList(entity.getPlanId(),dto);
|
||||||
if (!StringUtils.isBlank(dto.getPreDetailName()) && details.isEmpty()) {
|
//如果preDetailName不为空的情况下,且details为空,那么就去掉这个主数据
|
||||||
|
if (!StringUtils.isBlank(dto.getPreDetailName()) && query.isEmpty()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
List<ByPlanDetail> details = byPlanDetailMapper.selectList(entity.getPlanId(), null);
|
||||||
entity.setByPlanDetail(details);
|
entity.setByPlanDetail(details);
|
||||||
//根据用户id查询用户名称
|
//根据用户id查询用户名称
|
||||||
if(entity.getUserId() != null){
|
if(entity.getUserId() != null){
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,11 @@ public class ForecastDispatchPlanService extends ServiceImpl<ForecastDispatchPla
|
||||||
public Boolean deleteById(Serializable id) {
|
public Boolean deleteById(Serializable id) {
|
||||||
boolean flag = removeById(id);
|
boolean flag = removeById(id);
|
||||||
if(flag){
|
if(flag){
|
||||||
LambdaQueryChainWrapper<ForecastDispatchResult> eq = forecastDispatchResultService.lambdaQuery().eq(ForecastDispatchResult::getPlanId, id);
|
LambdaQueryWrapper<ForecastDispatchResult> eq1 = new LambdaQueryWrapper<>();
|
||||||
boolean remove = forecastDispatchResultService.remove(eq);
|
eq1.eq(ForecastDispatchResult::getPlanId, id);
|
||||||
LambdaQueryChainWrapper<ForecastDispatchCommand> eq2 = forecastDispatchCommandService.lambdaQuery().eq(ForecastDispatchCommand::getPlanId, id);
|
boolean remove = forecastDispatchResultService.remove(eq1);
|
||||||
|
LambdaQueryWrapper<ForecastDispatchCommand> eq2 = new LambdaQueryWrapper<>();
|
||||||
|
eq2.eq(ForecastDispatchCommand::getPlanId, id);
|
||||||
boolean remove2 = forecastDispatchCommandService.remove(eq2);
|
boolean remove2 = forecastDispatchCommandService.remove(eq2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.hsz.common.model.StFlowR;
|
||||||
import com.gunshi.project.hsz.entity.so.GateHisPageSo;
|
import com.gunshi.project.hsz.entity.so.GateHisPageSo;
|
||||||
import com.gunshi.project.hsz.entity.vo.AttResBaseVo;
|
import com.gunshi.project.hsz.entity.vo.AttResBaseVo;
|
||||||
import com.gunshi.project.hsz.entity.vo.GateStautsVo;
|
import com.gunshi.project.hsz.entity.vo.GateStautsVo;
|
||||||
|
|
@ -22,6 +23,7 @@ import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -29,6 +31,7 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 闸阀开关表
|
* 描述: 闸阀开关表
|
||||||
|
|
@ -124,38 +127,232 @@ public class GateValveRealService extends ServiceImpl<GateValveRealMapper, GateV
|
||||||
ExcelUtil.exportExcel(logList,"闸阀操作日志",GateValveOplogVo.class,response,"闸阀操作日志");
|
ExcelUtil.exportExcel(logList,"闸阀操作日志",GateValveOplogVo.class,response,"闸阀操作日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<BigDecimal, String> supplyTime(Integer year, Integer month) {
|
@Autowired
|
||||||
Map<BigDecimal, String> map = new HashMap<>();
|
private StEvpoService stEvpoService;
|
||||||
/**
|
|
||||||
* 可供水量= 实时库容 - 死库容
|
|
||||||
* 小时水量= (输水管流量 + 放水管流量)*3600
|
|
||||||
* 可供水小时数 = 可供水量 * 10000/ 小时水量
|
|
||||||
* 可供水天数 = 可供水小时数换算为天数
|
|
||||||
*/
|
|
||||||
List<AttResBaseVo> list = reservoirWaterService.list();
|
|
||||||
if(CollectionUtils.isEmpty(list)){
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
AttResBaseVo attResBaseVo = list.get(0);
|
|
||||||
BigDecimal nowCap = attResBaseVo.getNowCap() == null ? new BigDecimal(0) : attResBaseVo.getNowCap();
|
|
||||||
BigDecimal deadCap = attResBaseVo.getDeadCap() == null ? new BigDecimal(0) : attResBaseVo.getDeadCap();
|
|
||||||
|
|
||||||
BigDecimal supplyV = nowCap.subtract(deadCap);
|
@Autowired
|
||||||
if(year != null){
|
private StFlowRService stFlowRService;
|
||||||
//计算预测来水量
|
|
||||||
BigDecimal predictV = calcPredictV(year,month,attResBaseVo.getWatShedArea());
|
public Map<BigDecimal, String> supplyTime(Integer year, Integer month) {
|
||||||
supplyV = supplyV.add(predictV);
|
Map<BigDecimal, String> result = new HashMap<>();
|
||||||
|
|
||||||
|
// 获取所有月份的日蒸发量数据
|
||||||
|
List<StEvpo> allEvaporationData = stEvpoService.lambdaQuery().list();
|
||||||
|
Map<Integer, BigDecimal> evaporationMap = allEvaporationData.stream()
|
||||||
|
.collect(Collectors.toMap(StEvpo::getMonth, StEvpo::getEvaporation));
|
||||||
|
|
||||||
|
// 获取水库基础数据
|
||||||
|
List<AttResBaseVo> reservoirList = reservoirWaterService.list();
|
||||||
|
if (CollectionUtils.isEmpty(reservoirList)) {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
List<StWaterRReal> water = stWaterRRealMapper.listRelated();
|
AttResBaseVo reservoir = reservoirList.get(0);
|
||||||
//小时水量
|
|
||||||
BigDecimal hourQ = water.stream().map(StWaterRReal::getQ).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(new BigDecimal(3600));
|
// 初始可供水量 = 实时库容 - 死库容 (万m³)
|
||||||
BigDecimal day = supplyV.multiply(new BigDecimal(10000)).divide(hourQ.multiply(new BigDecimal(24)),1, RoundingMode.HALF_UP);
|
BigDecimal nowCap = reservoir.getNowCap() == null ? BigDecimal.ZERO : reservoir.getNowCap();
|
||||||
long l = DataHandleUtil.BigDecimalIntegerPart(day);
|
BigDecimal deadCap = reservoir.getDeadCap() == null ? BigDecimal.ZERO : reservoir.getDeadCap();
|
||||||
String date = DateUtil.getPlusDate(new Date(), l);
|
BigDecimal availableWater = nowCap.subtract(deadCap);
|
||||||
map.put(day,date);
|
|
||||||
return map;
|
// 如果初始可供水量就为0或负数,直接返回
|
||||||
|
if (availableWater.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
result.put(BigDecimal.ZERO, "当前无可供水量");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取当前流量数据
|
||||||
|
List<StFlowR> waterFlowList = stFlowRService.listNewData();
|
||||||
|
BigDecimal totalFlow = waterFlowList.stream()
|
||||||
|
.map(StFlowR::getQ)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
// 计算日供水量 (m³/d) 并转换为万m³/d
|
||||||
|
BigDecimal dailySupply = totalFlow.multiply(new BigDecimal(3600 * 24));
|
||||||
|
BigDecimal dailySupplyInTenThousand = dailySupply.divide(new BigDecimal(10000), 10, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
// 从当前时间开始计算
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int currentYear = calendar.get(Calendar.YEAR);
|
||||||
|
int currentMonth = calendar.get(Calendar.MONTH) + 1;
|
||||||
|
|
||||||
|
// 计算当前月份剩余天数
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||||
|
int daysInCurrentMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
|
||||||
|
int remainingDaysInMonth = daysInCurrentMonth - currentDay + 1;
|
||||||
|
|
||||||
|
BigDecimal totalSupplyDays = BigDecimal.ZERO;
|
||||||
|
BigDecimal remainingWater = availableWater;
|
||||||
|
|
||||||
|
// 判断是否计算预测水量
|
||||||
|
boolean calculatePredictWater = (year != null && month != null);
|
||||||
|
|
||||||
|
// 逐月计算,直到可供水量耗尽
|
||||||
|
int calcYear = currentYear;
|
||||||
|
int calcMonth = currentMonth;
|
||||||
|
boolean waterExhausted = false;
|
||||||
|
|
||||||
|
while (remainingWater.compareTo(BigDecimal.ZERO) > 0 && !waterExhausted) {
|
||||||
|
// 获取当前计算月份的蒸发量
|
||||||
|
String monthKey = String.valueOf(calcMonth);
|
||||||
|
BigDecimal monthlyEvaporation = evaporationMap.getOrDefault(Integer.valueOf(monthKey), BigDecimal.ZERO);
|
||||||
|
|
||||||
|
// 计算当前月份的预测来水量(只有当传入年份和月份不为空,且当前月份在预测范围内时才计算)
|
||||||
|
BigDecimal monthlyPredictWater = BigDecimal.ZERO;
|
||||||
|
if (calculatePredictWater && isMonthInPredictRange(calcMonth, currentMonth, month)) {
|
||||||
|
monthlyPredictWater = calcMonthlyPredictV(year, calcMonth, reservoir.getWatShedArea());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前月份总可用水量 = 剩余水量 + 预测来水量
|
||||||
|
BigDecimal monthlyTotalWater = remainingWater.add(monthlyPredictWater);
|
||||||
|
|
||||||
|
// 当前月份日消耗量 = 日供水量 + 日蒸发量 (万m³/d)
|
||||||
|
BigDecimal dailyConsumption = dailySupplyInTenThousand.add(monthlyEvaporation);
|
||||||
|
|
||||||
|
if (dailyConsumption.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
// 如果日消耗量为0或负数,说明可以无限供水
|
||||||
|
totalSupplyDays = new BigDecimal("9999"); // 表示无限期
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算当前月份可供水天数
|
||||||
|
int daysInMonth = getDaysInMonth(calcYear, calcMonth);
|
||||||
|
int daysToCalculate = (calcYear == currentYear && calcMonth == currentMonth) ?
|
||||||
|
remainingDaysInMonth : daysInMonth;
|
||||||
|
|
||||||
|
// 当前月份最大可供水量 = 日消耗量 * 当月剩余天数
|
||||||
|
BigDecimal monthlyMaxConsumption = dailyConsumption.multiply(new BigDecimal(daysToCalculate));
|
||||||
|
|
||||||
|
if (monthlyTotalWater.compareTo(monthlyMaxConsumption) >= 0) {
|
||||||
|
// 当前月份水量充足,可以支撑整个月
|
||||||
|
totalSupplyDays = totalSupplyDays.add(new BigDecimal(daysToCalculate));
|
||||||
|
remainingWater = monthlyTotalWater.subtract(monthlyMaxConsumption);
|
||||||
|
|
||||||
|
// 移动到下个月
|
||||||
|
calcMonth++;
|
||||||
|
if (calcMonth > 12) {
|
||||||
|
calcMonth = 1;
|
||||||
|
calcYear++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 当前月份水量不足,计算具体天数
|
||||||
|
BigDecimal remainingDays = monthlyTotalWater.divide(dailyConsumption, 1, RoundingMode.HALF_UP);
|
||||||
|
totalSupplyDays = totalSupplyDays.add(remainingDays);
|
||||||
|
waterExhausted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算结束日期
|
||||||
|
long totalDays = DataHandleUtil.BigDecimalIntegerPart(totalSupplyDays);
|
||||||
|
|
||||||
|
String endDate = DateUtil.getPlusDate(new Date(), totalDays);
|
||||||
|
|
||||||
|
result.put(totalSupplyDays, endDate);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前计算月份是否在预测范围内
|
||||||
|
* 预测范围:从当前月份到传入的截至月份
|
||||||
|
*/
|
||||||
|
private boolean isMonthInPredictRange(int calcMonth, int currentMonth, int endMonth) {
|
||||||
|
if (endMonth >= currentMonth) {
|
||||||
|
// 不跨年情况:当前月份 <= 计算月份 <= 截至月份
|
||||||
|
return calcMonth >= currentMonth && calcMonth <= endMonth;
|
||||||
|
} else {
|
||||||
|
// 跨年情况:计算月份 >= 当前月份 或者 计算月份 <= 截至月份
|
||||||
|
return calcMonth >= currentMonth || calcMonth <= endMonth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定年份月份的天数
|
||||||
|
*/
|
||||||
|
private int getDaysInMonth(int year, int month) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(Calendar.YEAR, year);
|
||||||
|
calendar.set(Calendar.MONTH, month - 1);
|
||||||
|
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// public Map<BigDecimal, String> supplyTime(Integer year, Integer month) {
|
||||||
|
// StEvpo stEvpo = stEvpoService.lambdaQuery().eq(StEvpo::getMonth, month.toString()).list().get(0);
|
||||||
|
// BigDecimal evpo = BigDecimal.ZERO; //蒸发量 (万m³
|
||||||
|
// if(stEvpo != null){
|
||||||
|
// evpo = stEvpo.getEvaporation();
|
||||||
|
// }
|
||||||
|
// Map<BigDecimal, String> map = new HashMap<>();
|
||||||
|
// /**
|
||||||
|
// * 可供水量= 实时库容 - 死库容
|
||||||
|
// * 小时水量= (输水管流量 + 放水管流量)*3600 ->改为 (输水管流量 + 放水管流量)*3600 + 蒸发量
|
||||||
|
// * 可供水小时数 = 可供水量 * 10000/ 小时水量 ->改为 (可供水量 + 预测水量如果有) * 10000 / 小时水量
|
||||||
|
// * 可供水天数 = 可供水小时数换算为天数
|
||||||
|
// */
|
||||||
|
// List<AttResBaseVo> list = reservoirWaterService.list();
|
||||||
|
// if(CollectionUtils.isEmpty(list)){
|
||||||
|
// return map;
|
||||||
|
// }
|
||||||
|
// AttResBaseVo attResBaseVo = list.get(0);
|
||||||
|
// BigDecimal nowCap = attResBaseVo.getNowCap() == null ? new BigDecimal(0) : attResBaseVo.getNowCap();
|
||||||
|
// BigDecimal deadCap = attResBaseVo.getDeadCap() == null ? new BigDecimal(0) : attResBaseVo.getDeadCap();
|
||||||
|
//
|
||||||
|
// BigDecimal supplyV = nowCap.subtract(deadCap);
|
||||||
|
// if(year != null){
|
||||||
|
// //计算预测来水量
|
||||||
|
// BigDecimal predictV = calcPredictV(year,month,attResBaseVo.getWatShedArea());
|
||||||
|
// supplyV = supplyV.add(predictV);
|
||||||
|
// }
|
||||||
|
// List<StWaterRReal> water = stWaterRRealMapper.listRelated();
|
||||||
|
// //小时水量
|
||||||
|
// BigDecimal hourQ = water.stream().map(StWaterRReal::getQ).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(new BigDecimal(3600));
|
||||||
|
// BigDecimal day = supplyV.multiply(new BigDecimal(10000)).divide(hourQ.multiply(new BigDecimal(24)),1, RoundingMode.HALF_UP);
|
||||||
|
// long l = DataHandleUtil.BigDecimalIntegerPart(day);
|
||||||
|
// String date = DateUtil.getPlusDate(new Date(), l);
|
||||||
|
// map.put(day,date);
|
||||||
|
// return map;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增方法:计算指定月份的预测来水量(独立月份计算)
|
||||||
|
* 例子:10.14-10.30预测水量为40,11.01-11.30预测水量为60
|
||||||
|
*/
|
||||||
|
private BigDecimal calcMonthlyPredictV(Integer year, Integer month, BigDecimal watShedArea) {
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
Integer nowMonth = now.getMonthValue();
|
||||||
|
|
||||||
|
// 查询指定月份的降雨量数据
|
||||||
|
LambdaQueryWrapper<TyYearRainfall> queryWrapper = Wrappers.lambdaQuery();
|
||||||
|
queryWrapper.eq(TyYearRainfall::getYear, year)
|
||||||
|
.eq(TyYearRainfall::getMonth, month)
|
||||||
|
.eq(TyYearRainfall::getType, 2);
|
||||||
|
|
||||||
|
TyYearRainfall rainfall = tyYearRainfallMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (rainfall == null || rainfall.getDrp() == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal monthlyRainfall = rainfall.getDrp();
|
||||||
|
|
||||||
|
// 如果是当前月份,需要按剩余天数比例计算
|
||||||
|
if (month.equals(nowMonth)) {
|
||||||
|
int dayOfMonth = now.getDayOfMonth();
|
||||||
|
int totalDaysInMonth = now.lengthOfMonth();
|
||||||
|
int remainingDays = totalDaysInMonth - dayOfMonth + 1;
|
||||||
|
|
||||||
|
// 按剩余天数比例计算当月有效降雨量
|
||||||
|
monthlyRainfall = new BigDecimal(remainingDays)
|
||||||
|
.multiply(monthlyRainfall)
|
||||||
|
.divide(new BigDecimal(totalDaysInMonth), 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
// 如果不是当前月份,则使用整月的降雨量(不需要按比例计算)
|
||||||
|
|
||||||
|
// 预测来水量 = 月降雨量 * 水库坝址控制流域面积 / 1000
|
||||||
|
BigDecimal sum = monthlyRainfall.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||||
|
return sum.multiply(watShedArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal calcPredictV(Integer year, Integer month,BigDecimal watShedArea) {
|
private BigDecimal calcPredictV(Integer year, Integer month,BigDecimal watShedArea) {
|
||||||
LocalDate now = LocalDate.now();
|
LocalDate now = LocalDate.now();
|
||||||
Integer nowMonth = now.getMonthValue();
|
Integer nowMonth = now.getMonthValue();
|
||||||
|
|
@ -189,6 +386,14 @@ public class GateValveRealService extends ServiceImpl<GateValveRealMapper, GateV
|
||||||
}
|
}
|
||||||
return calcPredictV(year,month,list.get(0).getWatShedArea());
|
return calcPredictV(year,month,list.get(0).getWatShedArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal predictWaterMonth(Integer year, Integer month) {
|
||||||
|
List<AttResBaseVo> list = reservoirWaterService.list();
|
||||||
|
if(CollectionUtils.isEmpty(list)){
|
||||||
|
return new BigDecimal(0);
|
||||||
|
}
|
||||||
|
return calcMonthlyPredictV(year,month,list.get(0).getWatShedArea());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
private ForecastResultsService forecastResultsService;//洪水预报
|
private ForecastResultsService forecastResultsService;//洪水预报
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public IcWaterForecast saveData(IcWaterForecast dto) {
|
public IcWaterForecast saveData(IcWaterForecast dto) {
|
||||||
BigDecimal totalWater = BigDecimal.ZERO;
|
BigDecimal totalWater = BigDecimal.ZERO;
|
||||||
dto.setCreateTime(LocalDateTime.now());
|
dto.setCreateTime(LocalDateTime.now());
|
||||||
|
|
@ -88,13 +90,22 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
}
|
}
|
||||||
|
|
||||||
public IcWaterForecast updateData(IcWaterForecast dto) {
|
public IcWaterForecast updateData(IcWaterForecast dto) {
|
||||||
icWaterForecastDetailService.removeByForecastId(dto.getId());
|
Long deleteId = dto.getId();
|
||||||
|
icWaterForecastDetailService.removeByForecastId(deleteId);
|
||||||
|
removeById(deleteId);
|
||||||
|
BigDecimal totalWater = BigDecimal.ZERO;
|
||||||
|
for (IcWaterForecastDetail detail : dto.getDetails()) {
|
||||||
|
totalWater = totalWater.add(detail.getForecastWater() != null?detail.getForecastWater():BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
dto.setForecastWater(totalWater);
|
||||||
|
dto.setCreateTime(LocalDateTime.now());
|
||||||
save(dto);
|
save(dto);
|
||||||
dto.getDetails().stream().forEach(item -> {
|
dto.getDetails().stream().forEach(item -> {
|
||||||
item.setIcWaterId(dto.getId());
|
item.setIcWaterId(dto.getId());
|
||||||
});
|
});
|
||||||
icWaterForecastDetailService.saveBatch(dto.getDetails());
|
icWaterForecastDetailService.saveBatch(dto.getDetails());
|
||||||
return dto;
|
return dto;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean delData(Serializable id) {
|
public Boolean delData(Serializable id) {
|
||||||
|
|
@ -135,12 +146,12 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
|
|
||||||
forecastTask.setForecastWarm(1);
|
forecastTask.setForecastWarm(1);
|
||||||
forecastTask.setForecastPeriod(hours); // 设置预报时长
|
forecastTask.setForecastPeriod(hours); // 设置预报时长
|
||||||
icWaterForecastDetails = shortForecast(forecastTask);
|
icWaterForecastDetails = shortForecast(forecastTask,uMap.get("dt"));
|
||||||
}
|
}
|
||||||
return icWaterForecastDetails;
|
return icWaterForecastDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IcWaterForecastDetail> shortForecast(ForecastTask forecastTask) {
|
private List<IcWaterForecastDetail> shortForecast(ForecastTask forecastTask,String dt) {
|
||||||
//进行洪水预测
|
//进行洪水预测
|
||||||
List<ForecastResultVo> humanForecastResult = forecastResultsService.getHumanForecastResult(forecastTask);
|
List<ForecastResultVo> humanForecastResult = forecastResultsService.getHumanForecastResult(forecastTask);
|
||||||
List<ForecastResultVo> collect = new ArrayList<>();
|
List<ForecastResultVo> collect = new ArrayList<>();
|
||||||
|
|
@ -158,7 +169,6 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
List<IcWaterForecastDetail> res = new ArrayList<>();
|
List<IcWaterForecastDetail> res = new ArrayList<>();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
if(humanForecastResult.size() > 0){
|
if(humanForecastResult.size() > 0){
|
||||||
|
|
||||||
for (int i = 0; i < collect.size(); i++) {
|
for (int i = 0; i < collect.size(); i++) {
|
||||||
IcWaterForecastDetail entity = new IcWaterForecastDetail();
|
IcWaterForecastDetail entity = new IcWaterForecastDetail();
|
||||||
//设置预测时间
|
//设置预测时间
|
||||||
|
|
@ -166,8 +176,26 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
if(i == 0){
|
if(i == 0){
|
||||||
entity.setForecastWater(BigDecimal.ZERO);
|
entity.setForecastWater(BigDecimal.ZERO);
|
||||||
}else{
|
}else{
|
||||||
BigDecimal water = collect.get(i).getNowCap().subtract(collect.get(i - 1).getNowCap());
|
if("1".equals(dt)){
|
||||||
entity.setForecastWater(water.multiply(new BigDecimal("10000")));//由万m³转为m³
|
ForecastResultVo current = collect.get(i);
|
||||||
|
BigDecimal water = BigDecimal.ZERO;
|
||||||
|
BigDecimal waterQGap = current.getYcRkQValue().subtract(current.getYcCkQValue());
|
||||||
|
water = waterQGap.multiply(new BigDecimal("3600"));
|
||||||
|
entity.setForecastWater(water.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}else{
|
||||||
|
//间隔为半小时
|
||||||
|
ForecastResultVo current = collect.get(i);//当前节点:时间为整点的数据
|
||||||
|
ForecastResultVo pre = collect.get(i - 1);//时间为30的节点
|
||||||
|
if(current.getTm().endsWith("30")){
|
||||||
|
continue;//跳过这条数据
|
||||||
|
}
|
||||||
|
BigDecimal water = BigDecimal.ZERO;
|
||||||
|
BigDecimal preQGap = pre.getYcRkQValue().subtract(pre.getYcCkQValue());
|
||||||
|
water = preQGap.multiply(new BigDecimal("1800"));
|
||||||
|
BigDecimal currentQGap = current.getYcRkQValue().subtract(current.getYcCkQValue());
|
||||||
|
water = water.add(currentQGap.multiply(new BigDecimal("1800")));
|
||||||
|
entity.setForecastWater(water.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.add(entity);
|
res.add(entity);
|
||||||
}
|
}
|
||||||
|
|
@ -242,6 +270,7 @@ public class IcWaterForecastService extends ServiceImpl<IcWaterForecastMapper, I
|
||||||
detail.setStartTime(monthStart);
|
detail.setStartTime(monthStart);
|
||||||
detail.setEndTime(monthEnd);
|
detail.setEndTime(monthEnd);
|
||||||
detail.setForecastWater(forecastWater);
|
detail.setForecastWater(forecastWater);
|
||||||
|
detail.setMonth(currentMonth);
|
||||||
result.add(detail);
|
result.add(detail);
|
||||||
|
|
||||||
// 移动到下个月
|
// 移动到下个月
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,16 @@ public class MentenceStDetailService extends ServiceImpl<MentenceStDetailMapper,
|
||||||
public Page<MentenceStDetail> pageQuery(MentenceStPageSo dto) {
|
public Page<MentenceStDetail> pageQuery(MentenceStPageSo dto) {
|
||||||
LambdaQueryWrapper<MentenceStDetail> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MentenceStDetail> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(MentenceStDetail::getMentenceStId,dto.getStId());
|
queryWrapper.eq(MentenceStDetail::getMentenceStId,dto.getStId());
|
||||||
|
queryWrapper.orderByAsc(MentenceStDetail::getOrder);
|
||||||
Page<MentenceStDetail> mentenceStDetailPage = baseMapper.selectPage(dto.getPageSo().toPage(), queryWrapper);
|
Page<MentenceStDetail> mentenceStDetailPage = baseMapper.selectPage(dto.getPageSo().toPage(), queryWrapper);
|
||||||
|
for (MentenceStDetail record : mentenceStDetailPage.getRecords()) {
|
||||||
|
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, record.getId());
|
||||||
|
Long count = mentencePlanDetailMapper.selectCount(queryWrapperDetail);
|
||||||
|
if(count > 0) {
|
||||||
|
record.setHasUse(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
return mentenceStDetailPage;
|
return mentenceStDetailPage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gunshi.project.hsz.entity.so.PrePlacePageSo;
|
import com.gunshi.project.hsz.entity.so.PrePlacePageSo;
|
||||||
|
import com.gunshi.project.hsz.mapper.ByLogDetailMapper;
|
||||||
import com.gunshi.project.hsz.mapper.ByPlanDetailMapper;
|
import com.gunshi.project.hsz.mapper.ByPlanDetailMapper;
|
||||||
import com.gunshi.project.hsz.mapper.PrePlaceDetailMapper;
|
import com.gunshi.project.hsz.mapper.PrePlaceDetailMapper;
|
||||||
import com.gunshi.project.hsz.mapper.PrePlaceMapper;
|
import com.gunshi.project.hsz.mapper.PrePlaceMapper;
|
||||||
|
|
@ -31,6 +32,9 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
||||||
@Autowired
|
@Autowired
|
||||||
private ByPlanDetailMapper byPlanDetailMapper;
|
private ByPlanDetailMapper byPlanDetailMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ByLogDetailMapper byLogDetailMapper;
|
||||||
|
|
||||||
public Page<PrePlaceDetail> pageQuery(PrePlacePageSo pageSo) {
|
public Page<PrePlaceDetail> pageQuery(PrePlacePageSo pageSo) {
|
||||||
if(StringUtils.isBlank(pageSo.getPreId())) {
|
if(StringUtils.isBlank(pageSo.getPreId())) {
|
||||||
throw new IllegalArgumentException("请选择防治点");
|
throw new IllegalArgumentException("请选择防治点");
|
||||||
|
|
@ -39,6 +43,13 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
||||||
query.eq(PrePlaceDetail::getPreId, pageSo.getPreId());
|
query.eq(PrePlaceDetail::getPreId, pageSo.getPreId());
|
||||||
query.orderByAsc(PrePlaceDetail::getOrder);
|
query.orderByAsc(PrePlaceDetail::getOrder);
|
||||||
Page<PrePlaceDetail> prePlaceDetailPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), query);
|
Page<PrePlaceDetail> prePlaceDetailPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), query);
|
||||||
|
for (PrePlaceDetail record : prePlaceDetailPage.getRecords()) {
|
||||||
|
int count1 = byPlanDetailMapper.selectByPPDI(record.getId());
|
||||||
|
int count2 = byLogDetailMapper.selectByPPDi(record.getId());
|
||||||
|
if(count1 > 0 || count2 > 0){
|
||||||
|
record.setHasUse(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
return prePlaceDetailPage;
|
return prePlaceDetailPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +71,11 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
||||||
if(count > 0){
|
if(count > 0){
|
||||||
throw new IllegalArgumentException("该防治点在防治计划中已被选择,不能删除");
|
throw new IllegalArgumentException("该防治点在防治计划中已被选择,不能删除");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int count2 = byLogDetailMapper.selectByPPDi(id);
|
||||||
|
if(count2 > 0){
|
||||||
|
throw new IllegalArgumentException("该防治点在日志记录中被使用,不能删除");
|
||||||
|
}
|
||||||
boolean b = removeById(id);
|
boolean b = removeById(id);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +85,10 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
||||||
if(count > 0){
|
if(count > 0){
|
||||||
throw new IllegalArgumentException("该防治点在防治计划中已被选择,不能编辑");
|
throw new IllegalArgumentException("该防治点在防治计划中已被选择,不能编辑");
|
||||||
}
|
}
|
||||||
|
int count2 = byLogDetailMapper.selectByPPDi(dto.getId());
|
||||||
|
if(count2 > 0){
|
||||||
|
throw new IllegalArgumentException("该防治点在日志记录中被使用,不能编辑");
|
||||||
|
}
|
||||||
boolean b = updateById(dto);
|
boolean b = updateById(dto);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.gunshi.project.hsz.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import cn.hutool.poi.excel.ExcelWriter;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.hsz.mapper.StEvpoMapper;
|
||||||
|
import com.gunshi.project.hsz.model.StEvpo;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class StEvpoService extends ServiceImpl<StEvpoMapper, StEvpo> {
|
||||||
|
public void export(HttpServletResponse response) {
|
||||||
|
List<StEvpo> list = this.lambdaQuery().orderByAsc(StEvpo::getMonth).list();
|
||||||
|
list.stream().forEach(o ->{
|
||||||
|
o.setEvaporation(o.getEvaporation().setScale(2));
|
||||||
|
});
|
||||||
|
// 通过工具类创建writer
|
||||||
|
ExcelWriter writer = ExcelUtil.getWriter();
|
||||||
|
|
||||||
|
// 自定义标题别名(只包含需要导出的字段)
|
||||||
|
writer.addHeaderAlias("month", "月份");
|
||||||
|
writer.addHeaderAlias("evaporation", "日蒸发量(万m³)");
|
||||||
|
|
||||||
|
// 只写出设置了别名的字段,默认写出所有字段
|
||||||
|
writer.setOnlyAlias(true);
|
||||||
|
|
||||||
|
// 一次性写出内容,使用默认样式
|
||||||
|
writer.write(list, true);
|
||||||
|
|
||||||
|
// 设置响应内容类型
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 设置响应头信息
|
||||||
|
String fileName = URLEncoder.encode("蒸发量数据", "UTF-8");
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||||
|
|
||||||
|
// 将writer对象刷新到响应输出流中
|
||||||
|
writer.flush(response.getOutputStream(), true);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 关闭writer,释放内存
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,8 +31,8 @@ public class StFlowRService extends ServiceImpl<StFlowRMapper, StFlowR> {
|
||||||
return baseMapper.selectOne(queryWrapper);
|
return baseMapper.selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StFlowRVo> listNewData() {
|
public List<StFlowR> listNewData() {
|
||||||
return voMapper.listNewData();
|
return this.baseMapper.listNewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getStcdList() {
|
public List<String> getStcdList() {
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ public class TyYearRainfallService extends ServiceImpl<TyYearRainfallMapper, TyY
|
||||||
public List<TyYearRainfallVo> queryList() {
|
public List<TyYearRainfallVo> queryList() {
|
||||||
LambdaQueryWrapper<TyYearRainfall> queryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TyYearRainfall> queryWrapper = Wrappers.lambdaQuery();
|
||||||
queryWrapper.eq(TyYearRainfall::getType,1);
|
queryWrapper.eq(TyYearRainfall::getType,1);
|
||||||
|
queryWrapper.orderByDesc(TyYearRainfall::getYear);
|
||||||
List<TyYearRainfall> list = this.list(queryWrapper);
|
List<TyYearRainfall> list = this.list(queryWrapper);
|
||||||
List<TyYearRainfallVo> resList = MyBeanUtil.collectionCopy(list,TyYearRainfallVo.class);
|
List<TyYearRainfallVo> resList = MyBeanUtil.collectionCopy(list,TyYearRainfallVo.class);
|
||||||
queryChild(resList);
|
queryChild(resList);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -31,6 +32,7 @@ public class XlPlanService extends ServiceImpl<XlPlanMapper, XlPlan> {
|
||||||
if(Objects.nonNull(xlPlan)){
|
if(Objects.nonNull(xlPlan)){
|
||||||
throw new IllegalArgumentException("该计划已存在,请检查");
|
throw new IllegalArgumentException("该计划已存在,请检查");
|
||||||
}
|
}
|
||||||
|
dto.setFillDate(new Date());
|
||||||
save(dto);
|
save(dto);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +54,7 @@ public class XlPlanService extends ServiceImpl<XlPlanMapper, XlPlan> {
|
||||||
if(pageSo.getType() != null){
|
if(pageSo.getType() != null){
|
||||||
queryWrapper.eq(XlPlan::getPlanType, pageSo.getType());
|
queryWrapper.eq(XlPlan::getPlanType, pageSo.getType());
|
||||||
}
|
}
|
||||||
|
queryWrapper.orderByDesc(XlPlan::getFillDate);
|
||||||
Page<XlPlan> xlPlanPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
Page<XlPlan> xlPlanPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||||
return xlPlanPage;
|
return xlPlanPage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue