李一帆 2025-09-11 16:24:38 +08:00
commit 852458f584
12 changed files with 180 additions and 17 deletions

View File

@ -41,14 +41,14 @@ public class MentenceInfoCountController extends AbstractCommonFileController {
return R.ok(byPage);
}
@Operation(summary = "根据时间统计隐患数目")
@Operation(summary = "根据时间统计 隐患 数目")
@PostMapping("/count12")
public R<List<MentenceInfoCount12Vo>> count12(@RequestBody MonthRangeSo monthRangeSo){
List<MentenceInfoCount12Vo> list = mentenceFarmerRecordService.count12(monthRangeSo);
return R.ok(list);
}
@Operation(summary = "根据时间统计隐患类型数目")
@Operation(summary = "根据时间统计 隐患类型 数目")
@PostMapping("/countType")
public R<Map<Integer,Integer>> countType(@RequestBody MonthRangeSo monthRangeSo){
Map<Integer,Integer> map = mentenceFarmerRecordService.countType(monthRangeSo);

View File

@ -3,6 +3,7 @@ package com.gunshi.project.hsz.controller;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.core.session.entity.SessionUser;
import com.gunshi.project.hsz.entity.so.WaterDispatchPageSo;
import com.gunshi.project.hsz.entity.so.XlPlanPageSo;
import com.gunshi.project.hsz.entity.vo.WdCountVo;
@ -16,6 +17,7 @@ import com.gunshi.project.hsz.validate.markers.Update;
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.HttpServletRequest;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -61,10 +63,15 @@ public class WaterDispatchController extends AbstractCommonFileController {
@Operation(summary = "反馈")
@PostMapping("/feedback")
public R<WaterDispatch> feedback(@RequestBody WaterDispatch dto) {
public R<WaterDispatch> feedback(@RequestBody WaterDispatch dto, HttpServletRequest request) {
SessionUser sessionUser = checkLogin(request);
if(sessionUser != null){
dto.setResPerson(sessionUser.getUserId().toString());
dto.setResPersonName(sessionUser.getUserName());
}
boolean flag = waterDispatchService.feedBack(dto);
if(flag){
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
fileService.saveFile(dto.getResFiles(),getResGroupId(),dto.getId().toString());
}
return R.ok(dto);
}
@ -89,6 +96,7 @@ public class WaterDispatchController extends AbstractCommonFileController {
boolean flag = waterDispatchService.removeById(id);
if(flag){
fileService.deleteFile(getGroupId(),byId.getId().toString());
fileService.deleteFile(getResGroupId(),byId.getId().toString());
}
return R.ok(true);
}
@ -98,9 +106,10 @@ public class WaterDispatchController extends AbstractCommonFileController {
public R<Page<WaterDispatch>> page(@RequestBody WaterDispatchPageSo pageSo) {
Page<WaterDispatch> res = waterDispatchService.pageQuery(pageSo);
if(!CollectionUtils.isEmpty(res.getRecords())){
res.getRecords().forEach(o -> o.setFiles(
fileService.getFiles(getGroupId(),o.getId().toString())
));
res.getRecords().stream().forEach(o ->{
o.setFiles(fileService.getFiles(getGroupId(),o.getId().toString()));
o.setResFiles(fileService.getFiles2(getResGroupId(),o.getId().toString()));
});
}
return R.ok(res);
}
@ -116,4 +125,8 @@ public class WaterDispatchController extends AbstractCommonFileController {
public String getGroupId() {
return "waterDispatch";
}
public String getResGroupId(){
return "waterDispatchRes";
}
}

View File

@ -24,14 +24,17 @@ public class StZqrlBVo {
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
//水位
private BigDecimal waterLevel;
//溢洪量
private BigDecimal flowNum;
//库容
private BigDecimal boxNum;
@Schema(description="流量和")
@Schema(description="累计溢洪量")
@TableField(exist = false)
private BigDecimal qtotal;

View File

@ -30,11 +30,34 @@ public interface FileAssociationsMapper extends BaseMapper<FileAssociations> {
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa."table_name" = #{tableName}
AND fd.group_id = #{tableName}
AND fd.group_id = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFiles(@Param("tableName") String tableName,@Param("businessId") String businessId);
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa."table_name" = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFiles2(@Param("tableName") String tableName,@Param("businessId") String businessId);
@Select("""
<script>
SELECT
@ -97,4 +120,7 @@ public interface FileAssociationsMapper extends BaseMapper<FileAssociations> {
</script>
""")
List<FileAssociations> getFilesByIds(@Param("ids") List<String> ids);
}

View File

@ -4,6 +4,8 @@ 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.validate.markers.Insert;
import com.gunshi.project.hsz.validate.markers.Update;
import io.swagger.v3.oas.annotations.media.Schema;
@ -19,6 +21,7 @@ import java.util.List;
@TableName("mentence_template")
public class MentenceTemplate {
@TableId
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@TableField("name")
@ -27,7 +30,7 @@ public class MentenceTemplate {
private String name;
@TableField("type")
@Schema(description = "模板类型")
@Schema(description = "模板类型 0 养护记录 1 验收记录")
@NotNull(message = "模板类型不能为空",groups = {Insert.class, Update.class})
private Integer type;

View File

@ -76,7 +76,7 @@ public class ResMangUnit implements Serializable {
@TableField(value="person_funds_source")
@Schema(description="人员经费来源")
// @Size(max = 0,message = "人员经费来源最大长度要小于 0")
private Integer personFundsSource;
private String personFundsSource;
/**
*
@ -84,7 +84,7 @@ public class ResMangUnit implements Serializable {
@TableField(value="repair_funds_source")
@Schema(description="维修养护经费来源")
// @Size(max = 0,message = "维修养护经费来源最大长度要小于 0")
private Integer repairFundsSource;
private String repairFundsSource;
/**
*

View File

@ -32,7 +32,7 @@ public class WaterDispatch {
private Long id;
@TableField(exist = false)
@TableField("is_distribute")
@Schema(description = "是否下发 0 是 1 否")
private Integer isDistribute;
@ -109,6 +109,19 @@ public class WaterDispatch {
@Schema(description = "执行结果反馈")
private String resFb;
@TableField("res_person")
@Schema(description = "反馈人员id")
private String resPerson;
@TableField("res_person_name")
@Schema(description = "反馈人员名称")
private String resPersonName;
@TableField("res_tm")
@Schema(description = "反馈时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date resTm;
/**
* 0 1
*/
@ -122,4 +135,9 @@ public class WaterDispatch {
@TableField(exist = false)
@Schema(description = "文件列表")
private List<FileAssociations> files;
@TableField(exist = false)
@Schema(description = "反馈文件列表")
private List<FileAssociations> resFiles;
}

View File

@ -210,6 +210,11 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
return this.baseMapper.getFiles(tName,bId);
}
public List<FileAssociations> getFiles2(String tName, String bId) {
return this.baseMapper.getFiles2(tName,bId);
}
@Cacheable(value = THIS_REDIS_KEY, key = "#p0 +':'+ #p1 +':'+ #p2", unless = "false")
public List<FileAssociations> getFiles(String tName, String bId,String num) {
return this.baseMapper.getFiles1(tName,bId,num);

View File

@ -182,7 +182,7 @@ public class RiverWaterService {
//查询该站点实时水位
StRiverRReal stRiverRReal = stRiverRRealService.getBaseMapper().queryQByStcd(stcd);
if(stRiverRReal == null){
throw new IllegalArgumentException("未查询到该站点实时水位信息,请检查");
return vo;
}
BigDecimal z = stRiverRReal.getZ() == null ? BigDecimal.ZERO : stRiverRReal.getZ();
vo.setWaterVal(z);

View File

@ -2,6 +2,7 @@ package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.mapper.StZvarlBMapper;
import com.gunshi.project.hsz.model.StZqrlB;
import com.gunshi.project.hsz.model.StZvarlB;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -72,6 +73,90 @@ public class StZvarlBService extends ServiceImpl<StZvarlBMapper, StZvarlB> {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
/**
* 线->
* ->
* @param zvarlBS
* @param rz
* @return
*/
public BigDecimal getWByZvarl(List<StZvarlB> zvarlBS, BigDecimal rz) {
// 1. 参数校验
if (zvarlBS == null || zvarlBS.isEmpty()) {
throw new IllegalArgumentException("水位-库容关系列表不能为空");
}
if (rz == null) {
throw new IllegalArgumentException("水位值不能为空");
}
// 2. 检查边界情况:如果目标水位低于最低水位或高于最高水位
BigDecimal minRz = zvarlBS.get(0).getRz();
BigDecimal maxRz = zvarlBS.get(zvarlBS.size() - 1).getRz();
if (rz.compareTo(minRz) < 0) {
// 低于最低水位,可以选择抛出异常或进行外推(这里选择抛出异常)
return BigDecimal.ZERO;
}
if (rz.compareTo(maxRz) > 0) {
// 高于最高水位,可以选择抛出异常或进行外推(这里选择抛出异常)
return BigDecimal.ZERO;
}
int l = 0;
int r = zvarlBS.size() -1;
//二分查找 由线性On时间复杂度降为Ologn
while (l <= r) {
int mid = l + (r-l) / 2;
BigDecimal midRz = zvarlBS.get(mid).getRz();
int compareResult = midRz.compareTo(rz);
if(compareResult == 0 ){
return zvarlBS.get(mid).getW();
}else if(compareResult < 0){
l = mid + 1;
}else{
r = mid - 1;
}
}
/**
* l rz
* r rz
* r x1 y1
* l x2 y2
*/
if(l < 0 || r >= zvarlBS.size()){
return BigDecimal.ZERO;
}
//获取前后差值的点
StZvarlB lowerPoint = zvarlBS.get(r);
StZvarlB upperPoint = zvarlBS.get(l);
return linearInterpolation(lowerPoint.getRz(),lowerPoint.getW(),upperPoint.getRz(),upperPoint.getW(),rz).setScale(3);
}
/**
* 线
* @param x1 1
* @param y1 1
* @param x2 2
* @param y2 2
* @param x
* @return
*/
private BigDecimal linearInterpolation(BigDecimal x1, BigDecimal y1,
BigDecimal x2, BigDecimal y2,
BigDecimal x) {
// 使用公式: y = y1 + ( (y2 - y1) / (x2 - x1) ) * (x - x1)
// 计算斜率: (y2 - y1) / (x2 - x1)
BigDecimal slope = y2.subtract(y1)
.divide(x2.subtract(x1), 10, RoundingMode.HALF_UP);
// 计算: slope * (x - x1)
BigDecimal xDiff = x.subtract(x1);
BigDecimal product = slope.multiply(xDiff);
// 计算最终结果: y1 + product
return y1.add(product);
}
}

View File

@ -41,11 +41,13 @@ public class WaterDispatchService extends ServiceImpl<WaterDispatchMapper, Water
dto.setExePersonName(sysUser.getNickName());
}
}
if(dto.getIsDistribute() == 0){//如果选择下发
if(dto.getIsDistribute() != null && dto.getIsDistribute() == 0){//如果选择下发
dto.setExeStatus(2);//状态改为下发中
}else{
dto.setExeStatus(1);//否则为待下发
dto.setIsDistribute(1);
}
dto.setFillTime(new Date());
save(dto);
return true;
}
@ -58,7 +60,8 @@ public class WaterDispatchService extends ServiceImpl<WaterDispatchMapper, Water
if(dto.getIsCompelete() == 0){
dto.setExeStatus(0);
}
dto.setFillTime(new Date());
dto.setResTm(new Date());
dto.setFillTime(byId.getFillTime());
updateById(dto);
return true;
}
@ -74,6 +77,12 @@ public class WaterDispatchService extends ServiceImpl<WaterDispatchMapper, Water
dto.setExePersonName(sysUser.getNickName());
}
}
if(dto.getIsDistribute() != null && dto.getIsDistribute() == 0){//如果选择下发
dto.setExeStatus(2);//状态改为下发中
}else{
dto.setExeStatus(1);//否则为待下发
dto.setIsDistribute(1);
}
updateById(dto);
return true;
}

View File

@ -19,6 +19,7 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -39,7 +40,7 @@ public class WaterRTask {
//每70分钟执行一次
// @Scheduled(fixedRate = 10 , timeUnit = TimeUnit.SECONDS)
//@Scheduled(fixedRate = 70 , timeUnit = TimeUnit.MINUTES)
public void syncDataToReorganize() {
LambdaQueryWrapper<StWaterRReorganize> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.orderByDesc(StWaterRReorganize::getTm)