修改了很多很多BUG

master
yangzhe123 2025-12-19 17:16:16 +08:00
parent 56333a6227
commit e5d6f25789
18 changed files with 451 additions and 89 deletions

View File

@ -43,7 +43,7 @@ public interface JcskGnssRMapper extends BaseMapper<JcskGnssR> {
t2.du, t2.du,
to_char(t2.tm,'YYYY-MM-DD HH24:MI:SS') as tm to_char(t2.tm,'YYYY-MM-DD HH24:MI:SS') as tm
from jcsk_gnss_b t1 from jcsk_gnss_b t1
left join ( join (
select t2.* select t2.*
from jcsk_gnss_r t2 from jcsk_gnss_r t2
join ( join (

View File

@ -95,7 +95,7 @@ public interface JcskSlBMapper extends BaseMapper<JcskSlB> {
<script> <script>
select t2.* select t2.*
from public.jcsk_sl_b t1 from public.jcsk_sl_b t1
left join public.jcsk_sl_r t2 join public.jcsk_sl_r t2
on t1.mpcd = t2.mpcd on t1.mpcd = t2.mpcd
where t1.dvcd in where t1.dvcd in
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")"> <foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">

View File

@ -211,7 +211,7 @@ public interface JcskSyRMapper extends BaseMapper<JcskSyR> {
<script> <script>
select t2.* select t2.*
from public.jcsk_sy_b t1 from public.jcsk_sy_b t1
left join public.jcsk_sy_r t2 join public.jcsk_sy_r t2
on t1.stcd =t2.stcd and t1.mpcd = t2.mpcd on t1.stcd =t2.stcd and t1.mpcd = t2.mpcd
where t1.dvcd in where t1.dvcd in
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")"> <foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">

View File

@ -0,0 +1,89 @@
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.entity.so.WaterCommonSo;
import com.gunshi.project.hsz.entity.vo.AttResBaseVo;
import com.gunshi.project.hsz.entity.vo.ResWarnVo;
import com.gunshi.project.hsz.entity.vo.ResWarningVo;
import com.gunshi.project.hsz.entity.vo.SKWarningVo;
import com.gunshi.project.hsz.mapper.AttResBaseMapper;
import com.gunshi.project.hsz.model.ResSafePersonB;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@Tag(name = "水库建筑物 - 放空洞/灌溉发电洞")
@RestController
@RequestMapping(value="/current/situation")
public class ResWarnController {
@Autowired
private AttResBaseMapper attResBaseMapper;
@Operation(summary = "预警")
@PostMapping("/res/warn")
public R<ResWarnVo> warn(@Validated(Insert.class) @RequestBody WaterCommonSo dto) {
ResWarnVo vo = new ResWarnVo();
List<AttResBaseVo> attResBaseVos = attResBaseMapper.queryList2();
List<ResWarningVo> calFloodLevList = new ArrayList<>();
List<ResWarningVo> desFloodLevList = new ArrayList<>();
List<ResWarningVo> aboutAFsltdzList = new ArrayList<>();
vo.setCalFloodLevList(calFloodLevList);
vo.setDesFloodLevList(desFloodLevList);
vo.setAboutAFsltdzList(aboutAFsltdzList);
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date currentDate = now.getTime();
for (AttResBaseVo attResBaseVo : attResBaseVos) {
Date tm = attResBaseVo.getTm();
if(tm == null){
continue;
}
//水位的最新采集时间不在24小时内
if (tm.before(currentDate)) {
continue;
}else{
BigDecimal rz = attResBaseVo.getRz();
if(rz == null){
continue;
}
ResWarningVo resWarningVo = new ResWarningVo();
resWarningVo.setLttd(attResBaseVo.getLttd());
resWarningVo.setLgtd(attResBaseVo.getLgtd());
resWarningVo.setStnm(attResBaseVo.getStnm());
resWarningVo.setStcd(attResBaseVo.getStcd());
resWarningVo.setRz(rz);
if (attResBaseVo.getCalState() == 1) {
BigDecimal aboveCal = rz.subtract(attResBaseVo.getCalFloodLev());
resWarningVo.setAfsltdz(aboveCal);
calFloodLevList.add(resWarningVo);
} else if (attResBaseVo.getDesState() == 1) {
BigDecimal aboveDes = rz.subtract(attResBaseVo.getDesFloodLev());
resWarningVo.setAfsltdz(aboveDes);
desFloodLevList.add(resWarningVo);
} else if (attResBaseVo.getFlState() == 1) {
BigDecimal aboveFl = attResBaseVo.getAFsltdz().setScale(2, RoundingMode.HALF_UP);
resWarningVo.setAfsltdz(aboveFl);
aboutAFsltdzList.add(resWarningVo);
}
}
}
return R.ok(vo);
}
}

View File

@ -47,6 +47,7 @@ public class RiverWaterController {
return R.ok(riverWaterService.list()); return R.ok(riverWaterService.list());
} }
@Get(path = "/zqrl", summary = "水位流量关系") @Get(path = "/zqrl", summary = "水位流量关系")
public R<List<StZqR>> zqrl(@Schema(name = "stcd") @RequestParam("stcd") String stcd) { public R<List<StZqR>> zqrl(@Schema(name = "stcd") @RequestParam("stcd") String stcd) {
return R.ok(riverWaterService.zqr(stcd)); return R.ok(riverWaterService.zqr(stcd));

View File

@ -0,0 +1,29 @@
package com.gunshi.project.hsz.entity.so;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
*
* Created by wanyan on 2024/3/11
*
* @author wanyan
* @version 1.0
*/
@Data
public class WaterCommonSo {
@Schema(description ="来源")
private List<String> sources;
@Schema(description ="站点名称或编码")
private String args;
@Schema(description ="行政区划编码(仅APP乡镇用户需要传参)")
private String adcd;
@Schema(description ="预警类型(仅APP需要传参,水库1超校核 2超设计 3超讯限 河道1超危险 2超警戒)")
private List<Integer> types;
}

View File

@ -0,0 +1,19 @@
package com.gunshi.project.hsz.entity.vo;
import lombok.Data;
import java.util.List;
@Data
public class ResWarnVo {
private List<ResWarningVo> calFloodLevList;
private List<ResWarningVo> desFloodLevList;
private List<ResWarningVo> aboutAFsltdzList;
}

View File

@ -0,0 +1,28 @@
package com.gunshi.project.hsz.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ResWarningVo {
@Schema(description = "站点编码")
private String stcd;
@Schema(description = "站点名称")
private String stnm;
@Schema(description = "经度")
private BigDecimal lgtd;
@Schema(description = "纬度")
private BigDecimal lttd;
private BigDecimal afsltdz;
private BigDecimal rz;
}

View File

@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -91,9 +92,15 @@ public class HisWaterDataService extends ServiceImpl<HisWaterDataMapper, HisWate
checkParam(dto); checkParam(dto);
HisWaterData hisWaterData = new HisWaterData(); HisWaterData hisWaterData = new HisWaterData();
BeanUtils.copyProperties(dto,hisWaterData); BeanUtils.copyProperties(dto,hisWaterData);
if(dto.getChildren() == null || dto.getChildren().isEmpty()){
dto.setAvgWater(BigDecimal.ZERO);
}
updateById(hisWaterData); updateById(hisWaterData);
deleteMonthData(dto.getYear()); deleteMonthData(dto.getYear());
List<HisWaterData> list = dto.getChildren(); List<HisWaterData> list = dto.getChildren();
list.stream().forEach(o ->{
o.setYear(dto.getYear());
});
return saveBatch(list); return saveBatch(list);
} }

View File

@ -131,6 +131,9 @@ public class InspectTaskDetailService extends ServiceImpl<InspectTaskDetailMappe
} }
for(InspectTaskDetailVo vo : list){ for(InspectTaskDetailVo vo : list){
InspectTaskDetail detail = new InspectTaskDetail(); InspectTaskDetail detail = new InspectTaskDetail();
detail.setHandleTime(new Date());
detail.setHandleUserId(vo.getHandleUserId());
detail.setHandleUserName(vo.getHandleUserName());
BeanUtils.copyProperties(vo,detail); BeanUtils.copyProperties(vo,detail);
res.add(detail); res.add(detail);
fileService.save(vo.getInspectPics(),vo.getId().toString(),getGroupId(),getPicType()); fileService.save(vo.getInspectPics(),vo.getId().toString(),getGroupId(),getPicType());

View File

@ -134,27 +134,12 @@ public class ReservoirWaterService {
}else if(vo.getCalState() == 0 && vo.getDesState() ==1){ }else if(vo.getCalState() == 0 && vo.getDesState() ==1){
vo.setFlState(0); vo.setFlState(0);
} }
//如果最新数据时间小于当前时间整点,那么不显示水位数据(他妈的,很多功能都是复用一个接口的,说实话,不知道以前的人怎么设计的,就单一责任原则不好吗,非得复用代码,这下搞得需求有变更的情况下,一个页面改好了,另一个页面又会出现问题,真是服了)
Date tm = vo.getTm();
BigDecimal rz = vo.getRz(); BigDecimal rz = vo.getRz();
// 获取当前时间整点(去掉分钟和秒) if (rz != null) {
Calendar now = Calendar.getInstance(); //BigDecimal w = stZvarlBService.getWFromZvarl(rz, null, zvarlList);
now.set(Calendar.MINUTE, 0); BigDecimal w = stZvarlBService.getWByZvarl(zvarlList,rz);
now.set(Calendar.SECOND, 0); vo.setNowCap(w);
now.set(Calendar.MILLISECOND, 0);
Date currentHour = now.getTime();
if(tm != null && tm.before(currentHour)){
vo.setRz(null);
vo.setTm(null);
}else if (tm != null && rz != null){
if (rz != null) {
//BigDecimal w = stZvarlBService.getWFromZvarl(rz, null, zvarlList);
BigDecimal w = stZvarlBService.getWByZvarl(zvarlList,rz);
vo.setNowCap(w);
}
} }
}); });
//TODO 计算2个灌溉站的流量之和 //TODO 计算2个灌溉站的流量之和
@ -213,30 +198,62 @@ public class ReservoirWaterService {
}else if(vo.getCalState() == 0 && vo.getDesState() ==1){ }else if(vo.getCalState() == 0 && vo.getDesState() ==1){
vo.setFlState(0); vo.setFlState(0);
} }
//如果最新数据时间小于当前时间整点,那么不显示水位数据(他妈的,很多功能都是复用一个接口的,说实话,不知道以前的人怎么设计的,就单一责任原则不好吗,非得复用代码,这下搞得需求有变更的情况下,一个页面改好了,另一个页面又会出现问题,真是服了)
Date tm = vo.getTm();
BigDecimal rz = vo.getRz(); BigDecimal rz = vo.getRz();
// 获取当前时间整点(去掉分钟和秒)
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date currentHour = now.getTime();
if(tm != null && tm.before(currentHour)){
vo.setRz(null);
vo.setTm(null);
}else if (tm != null && rz != null){
if (rz != null) { if (rz != null) {
//BigDecimal w = stZvarlBService.getWFromZvarl(rz, null, zvarlList); //BigDecimal w = stZvarlBService.getWFromZvarl(rz, null, zvarlList);
BigDecimal w = stZvarlBService.getWByZvarl(zvarlList,rz); BigDecimal w = stZvarlBService.getWByZvarl(zvarlList,rz);
vo.setNowCap(w); vo.setNowCap(w);
} }
}
}); });
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date currentHour = now.getTime();
//TODO 计算2个灌溉站的流量之和 //TODO 计算2个灌溉站的流量之和
BigDecimal totalSum = BigDecimal.ZERO; BigDecimal totalSum = null;
String stcd1 = "1112"; String stcd1 = "1112";
QueryWrapper<StWaterRReal> irrQw1 = new QueryWrapper<>(); QueryWrapper<StWaterRReal> irrQw1 = new QueryWrapper<>();
irrQw1.eq("stcd", stcd1).orderBy(true, false, "tm"); irrQw1.eq("stcd", stcd1).orderBy(true, false, "tm");
StWaterRReal stWaterRReal1 = stWaterRRealService.getOne(irrQw1); StWaterRReal stWaterRReal1 = stWaterRRealService.getOne(irrQw1);
if(stWaterRReal1 != null){
totalSum = totalSum.add(stWaterRReal1.getQ());
}
String stcd2 = "1113"; String stcd2 = "1113";
QueryWrapper<StWaterRReal> irrQw2 = new QueryWrapper<>(); QueryWrapper<StWaterRReal> irrQw2 = new QueryWrapper<>();
irrQw2.eq("stcd", stcd2).orderBy(true, false, "tm"); irrQw2.eq("stcd", stcd2).orderBy(true, false, "tm");
StWaterRReal stWaterRReal2 = stWaterRRealService.getOne(irrQw2); StWaterRReal stWaterRReal2 = stWaterRRealService.getOne(irrQw2);
if(stWaterRReal2 != null){ if(stWaterRReal1 != null ){
totalSum = totalSum.add(stWaterRReal2.getQ()); Date tm1 = stWaterRReal1.getTm();
if(tm1 != null && !tm1.before(currentHour)){
totalSum = BigDecimal.ZERO;
totalSum = totalSum.add(stWaterRReal1.getQ());
}
} }
if(stWaterRReal2 != null){
Date tm2 = stWaterRReal2.getTm();
if(tm2 != null && !tm2.before(currentHour)){
if(totalSum == null){
totalSum = BigDecimal.ZERO;
}
totalSum = totalSum.add(stWaterRReal2.getQ());
}
}
for (AttResBaseVo attResBaseVo : voList) { for (AttResBaseVo attResBaseVo : voList) {
//设置灌溉流量 //设置灌溉流量
attResBaseVo.setIrrigationFlowSum(totalSum); attResBaseVo.setIrrigationFlowSum(totalSum);
@ -253,10 +270,13 @@ public class ReservoirWaterService {
ecologyQw.eq("stcd", ecologyStcd).orderBy(true, false, "tm"); ecologyQw.eq("stcd", ecologyStcd).orderBy(true, false, "tm");
StWaterRReal ecologyWaterRReal = stWaterRRealService.getOne(ecologyQw); StWaterRReal ecologyWaterRReal = stWaterRRealService.getOne(ecologyQw);
if(ecologyWaterRReal != null){ if(ecologyWaterRReal != null){
voList.stream().forEach(o -> { Date tm = ecologyWaterRReal.getTm();
o.setEcologyFlow(ecologyWaterRReal.getQ()); if(tm != null && !tm.before(currentHour)){
o.setEcologyFlowTm(ecologyWaterRReal.getTm()); voList.stream().forEach(o -> {
}); o.setEcologyFlow(ecologyWaterRReal.getQ());
o.setEcologyFlowTm(ecologyWaterRReal.getTm());
});
}
} }
return voList; return voList;
} }

View File

@ -291,7 +291,7 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
List<Integer> sortedMonths = monthSet.stream() List<Integer> sortedMonths = monthSet.stream()
.sorted() .sorted()
.collect(Collectors.toList()); .collect(Collectors.toList());
//boolean isFirst = true;
for (Integer sortedMonth : sortedMonths) { for (Integer sortedMonth : sortedMonths) {
RiceIrrigationUse riceIrrigationUse = new RiceIrrigationUse(); RiceIrrigationUse riceIrrigationUse = new RiceIrrigationUse();
riceIrrigationUse.setMonth(sortedMonth); riceIrrigationUse.setMonth(sortedMonth);
@ -317,11 +317,15 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
irrigationVolume = irrigationVolume.add(growConsumption); irrigationVolume = irrigationVolume.add(growConsumption);
// 计算该月份所有生育阶段的总有效降雨量 // 计算该月份所有生育阶段的总有效降雨量
// if(isMonthInKaPeriod(sortedMonth, kaStartTime, kaEndTime) && !isFirst){
// growPeriods.addFirst(kaPeriod);
// }
BigDecimal monthlyRainfall = calculateTotalEffectiveRainfallForMonth(sortedMonth, growPeriods, list); BigDecimal monthlyRainfall = calculateTotalEffectiveRainfallForMonth(sortedMonth, growPeriods, list);
// if(isMonthInKaPeriod(sortedMonth, kaStartTime, kaEndTime) && !isFirst){
// growPeriods.removeFirst();
// }
irrigationVolume = irrigationVolume.subtract(monthlyRainfall); irrigationVolume = irrigationVolume.subtract(monthlyRainfall);
// // 如果计算结果是负数则设为0
// 如果计算结果是负数则设为0
// if (irrigationVolume.compareTo(BigDecimal.ZERO) < 0) { // if (irrigationVolume.compareTo(BigDecimal.ZERO) < 0) {
// irrigationVolume = BigDecimal.ZERO; // irrigationVolume = BigDecimal.ZERO;
// } // }
@ -331,6 +335,7 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
riceIrrigationUse.setIrrigationUse(irrigationVolume); riceIrrigationUse.setIrrigationUse(irrigationVolume);
res.add(riceIrrigationUse); res.add(riceIrrigationUse);
// isFirst = false;
} }
return res; return res;
} }
@ -472,20 +477,24 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
//灌溉区面积(亩) //灌溉区面积(亩)
BigDecimal sArea = riceGrowConfig.getArea(); BigDecimal sArea = riceGrowConfig.getArea();
sArea = sArea.multiply(new BigDecimal("10000"));
for (RiceIrrigationUse riceIrrigationUse : riceIrrigationUses) { for (RiceIrrigationUse riceIrrigationUse : riceIrrigationUses) {
RiceWaterForecastMonth entity = new RiceWaterForecastMonth(); RiceWaterForecastMonth entity = new RiceWaterForecastMonth();
entity.setMonth(riceIrrigationUse.getMonth()); entity.setMonth(riceIrrigationUse.getMonth());
BigDecimal irrigationUse = riceIrrigationUse.getIrrigationUse(); BigDecimal irrigationUse = riceIrrigationUse.getIrrigationUse();
// 计算公式2/3 * irrigationUse * sArea / 10000 if(irrigationUse.compareTo(BigDecimal.ZERO) <= 0){
BigDecimal value = new BigDecimal("2") entity.setIrrigationUse(BigDecimal.ZERO);
.divide(new BigDecimal("3"), 9, RoundingMode.HALF_UP) // 2/3保留10位小数 }else{
.multiply(irrigationUse) // 计算公式2/3 * irrigationUse * sArea / 10000
.multiply(sArea) BigDecimal value = new BigDecimal("2")
.divide(new BigDecimal("10000")); // 除以10000保留2位小数 .divide(new BigDecimal("3"), 20, RoundingMode.HALF_UP) // 2/3保留10位小数
.multiply(irrigationUse)
.multiply(sArea)
.divide(new BigDecimal("10000")); // 除以10000保留2位小数
entity.setIrrigationUse(value);
}
entity.setIrrigationUse(value);
res.add(entity); res.add(entity);
} }
return res; return res;
@ -528,16 +537,20 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
res.add(data); res.add(data);
} }
} }
sArea = sArea.multiply(new BigDecimal("10000"));
for (RiceWaterForecastCycle re : res) { for (RiceWaterForecastCycle re : res) {
BigDecimal irrigationUse = re.getIrrigationUse(); BigDecimal irrigationUse = re.getIrrigationUse();
if(irrigationUse.compareTo(BigDecimal.ZERO) <=0){
re.setIrrigationUse(BigDecimal.ZERO);
}else{
BigDecimal value = new BigDecimal("2")
.divide(new BigDecimal("3"), 20, RoundingMode.HALF_UP) // 2/3保留10位小数
.multiply(irrigationUse)
.multiply(sArea)
.divide(new BigDecimal("10000")); // 除以10000保留2位小数
re.setIrrigationUse(value);
}
BigDecimal value = new BigDecimal("2")
.divide(new BigDecimal("3"), 9, RoundingMode.HALF_UP) // 2/3保留10位小数
.multiply(irrigationUse)
.multiply(sArea)
.divide(new BigDecimal("10000")); // 除以10000保留2位小数
re.setIrrigationUse(value);
} }
return res; return res;
} }
@ -560,7 +573,7 @@ public class RiceRqWaterService extends ServiceImpl<RiceRqWaterMapper, RiceRqWat
BigDecimal irrigationUse = stageWaterUse.subtract(effectiveRainfall); BigDecimal irrigationUse = stageWaterUse.subtract(effectiveRainfall);
// 确保不会出现负值 // 确保不会出现负值
return irrigationUse.compareTo(BigDecimal.ZERO) > 0 ? irrigationUse : BigDecimal.ZERO; return irrigationUse;
} }
/** /**

View File

@ -66,17 +66,17 @@ public class RiverWaterService {
if(CollectionUtils.isEmpty(attRvBaseVos)){ if(CollectionUtils.isEmpty(attRvBaseVos)){
return attRvBaseVos; return attRvBaseVos;
} }
for (AttRvBaseVo attRvBaseVo : attRvBaseVos) { // for (AttRvBaseVo attRvBaseVo : attRvBaseVos) {
Date tm = attRvBaseVo.getTm(); // Date tm = attRvBaseVo.getTm();
Calendar now = Calendar.getInstance(); // Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0); // now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0); // now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0); // now.set(Calendar.MILLISECOND, 0);
Date currentDate = now.getTime(); // Date currentDate = now.getTime();
if(tm.before(currentDate)){ // if(tm.before(currentDate)){
attRvBaseVo.setZ(null); // attRvBaseVo.setZ(null);
} // }
} // }
return attRvBaseVos; return attRvBaseVos;
} }

View File

@ -7,6 +7,8 @@ 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.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -25,7 +27,26 @@ public class StPptnRRealService extends ServiceImpl<StPptnRRealMapper, StPptnRRe
} }
public List<StPptnRReal> queryList() { public List<StPptnRReal> queryList() {
return this.baseMapper.queryList(); List<StPptnRReal> stPptnRReals = this.baseMapper.queryList();
if(!stPptnRReals.isEmpty()){
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date currentHour = now.getTime();
for (StPptnRReal stPptnRReal : stPptnRReals) {
Date tm = stPptnRReal.getTm();
if(tm != null && tm.before(currentHour)){
stPptnRReal.setH1(null);
stPptnRReal.setH3(null);
stPptnRReal.setH6(null);
stPptnRReal.setH12(null);
stPptnRReal.setH24(null);
}
}
}
return stPptnRReals;
} }
} }

View File

@ -199,7 +199,7 @@ public class StQxWarnRService extends ServiceImpl<StQxWarnRMapper, StQxWarnR> {
setUpAndDownOverRvUpAndDown(upperStcd,dateTimeRangeSo,overWarn,overPmis); setUpAndDownOverRvUpAndDown(upperStcd,dateTimeRangeSo,overWarn,overPmis);
//TODO 超河道下游 //TODO 超河道下游
String lowerStcd = "61610700";//固定的站点编码 String lowerStcd = "999999998";//固定的站点编码
setUpAndDownOverRvUpAndDown(lowerStcd,dateTimeRangeSo,overWarn,overPmis); setUpAndDownOverRvUpAndDown(lowerStcd,dateTimeRangeSo,overWarn,overPmis);
riverWarningVoMap.put("overWarn",overWarn); riverWarningVoMap.put("overWarn",overWarn);
riverWarningVoMap.put("overPromise",overPmis); riverWarningVoMap.put("overPromise",overPmis);

View File

@ -26,22 +26,6 @@ public class StWaterRRealService extends ServiceImpl<StWaterRRealMapper, StWater
public List<StWaterRReal> listRelated() { public List<StWaterRReal> listRelated() {
List<StWaterRReal> stWaterRReals = baseMapper.listRelated(); List<StWaterRReal> stWaterRReals = baseMapper.listRelated();
if(stWaterRReals != null && stWaterRReals.size() > 0){
for (StWaterRReal vo : stWaterRReals) {
Date tm = vo.getTm();
if(tm != null){
Calendar now = Calendar.getInstance();
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date currentDate = now.getTime();
if(tm.before(currentDate)){
vo.setQ(null);
vo.setV(null);
}
}
}
}
return stWaterRReals; return stWaterRReals;
} }

View File

@ -0,0 +1,136 @@
package com.gunshi.project.hsz.system;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RestController
@RequestMapping("/appUpdate")
@Tag(name = "app端更新")
public class AppUpdateController {
private static final String BASE_PATH = "/app/uploadPath/upload";
@GetMapping("/getApp/**")
public void downloadFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
// 1. 获取URI
String uri = request.getRequestURI();
System.out.println("收到请求URI: " + uri);
// 2. 使用正则表达式提取日期部分和文件名
// 匹配模式:/YYYY/MM/DD/文件名.apk
Pattern pattern = Pattern.compile("/(\\d{4}/\\d{2}/\\d{2}/[^/]+\\.apk)");
Matcher matcher = pattern.matcher(uri);
String path;
if (matcher.find()) {
// 找到日期文件路径例如2025/12/19/__UNI__DB7153B__20251218172415(1)_20251219102301A001.apk
path = matcher.group(1);
System.out.println("提取的日期文件路径: " + path);
} else {
// 如果没有找到日期格式的路径,使用原来的逻辑
// 找到 "/getApp/" 的位置
int startIndex = uri.indexOf("/getApp/");
if (startIndex == -1) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "URL格式错误");
return;
}
// 提取路径(去掉"/getApp/"
path = uri.substring(startIndex + "/getApp/".length());
System.out.println("提取的相对路径: " + path);
// 可选:移除可能的前缀如 "profile/upload/"
if (path.startsWith("profile/upload/")) {
path = path.substring("profile/upload/".length());
System.out.println("移除profile/upload前缀后: " + path);
}
}
// 3. 构建文件路径
String fullPath = BASE_PATH + "/" + path;
System.out.println("完整文件路径: " + fullPath);
File file = new File(fullPath);
// 4. 检查文件是否存在
if (!file.exists()) {
System.out.println("文件不存在: " + fullPath);
response.sendError(HttpServletResponse.SC_NOT_FOUND, "文件不存在");
return;
}
if (!file.isFile()) {
System.out.println("不是文件: " + fullPath);
response.sendError(HttpServletResponse.SC_NOT_FOUND, "不是有效的文件");
return;
}
System.out.println("文件大小: " + file.length() + " bytes");
// 5. 设置响应头
String fileName = file.getName();
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString())
.replaceAll("\\+", "%20");
// 根据文件扩展名设置Content-Type
String contentType = getContentType(fileName);
response.setContentType(contentType);
response.setHeader("Content-Disposition",
"attachment; filename=\"" + encodedFileName + "\"");
response.setContentLengthLong(file.length());
// 6. 流式传输文件
try (InputStream in = new FileInputStream(file);
OutputStream out = response.getOutputStream()) {
byte[] buffer = new byte[8192]; // 使用8KB缓冲区
int bytesRead;
long totalBytes = 0;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
totalBytes += bytesRead;
}
System.out.println("成功传输字节数: " + totalBytes);
out.flush();
} catch (IOException e) {
// 客户端可能中断了下载
System.out.println("下载中断或错误: " + e.getMessage());
if (!e.getMessage().contains("Broken pipe") &&
!e.getMessage().contains("Connection reset")) {
throw e;
}
}
}
/**
* Content-Type
*/
private String getContentType(String fileName) {
if (fileName.toLowerCase().endsWith(".apk")) {
return "application/vnd.android.package-archive";
} else if (fileName.toLowerCase().endsWith(".ipa")) {
return "application/iphone";
} else if (fileName.toLowerCase().endsWith(".txt")) {
return "text/plain";
} else if (fileName.toLowerCase().endsWith(".pdf")) {
return "application/pdf";
} else if (fileName.toLowerCase().endsWith(".zip")) {
return "application/zip";
} else {
return "application/octet-stream";
}
}
}

View File

@ -195,13 +195,17 @@ public class JcskDataTask {
so.setEnd(new Date()); so.setEnd(new Date());
osmoticQuerySo.setDateTimeRangeSo(so); osmoticQuerySo.setDateTimeRangeSo(so);
List<JcskSlR> osmoticValueVo2s = jcskSlBMapper.syncqueryValue(osmoticQuerySo); List<JcskSlR> osmoticValueVo2s = jcskSlBMapper.syncqueryValue(osmoticQuerySo);
syncData.add(osmoticValueVo2s); if(!osmoticValueVo2s.isEmpty()){
syncData.add(osmoticValueVo2s);
}
} }
} else { } else {
//全量同步 //全量同步
osmoticQuerySo.setStationCodes(cds); osmoticQuerySo.setStationCodes(cds);
List<JcskSlR> osmoticValueVo2s = jcskSlBMapper.syncqueryValue(osmoticQuerySo); List<JcskSlR> osmoticValueVo2s = jcskSlBMapper.syncqueryValue(osmoticQuerySo);
syncData.add(osmoticValueVo2s); if(!osmoticValueVo2s.isEmpty()){
syncData.add(osmoticValueVo2s);
}
} }
// 使用 DateTimeFormatter 替代 SimpleDateFormat // 使用 DateTimeFormatter 替代 SimpleDateFormat
@ -313,13 +317,17 @@ public class JcskDataTask {
so.setEnd(DateTransforUtil.transforLocalDateTimeToDate(LocalDateTime.now())); so.setEnd(DateTransforUtil.transforLocalDateTimeToDate(LocalDateTime.now()));
osmoticQuerySo.setDateTimeRangeSo(so); osmoticQuerySo.setDateTimeRangeSo(so);
List<JcskSyR> osmoticValueVo2s = jcskSyRService.getBaseMapper().syncqueryValue(osmoticQuerySo); List<JcskSyR> osmoticValueVo2s = jcskSyRService.getBaseMapper().syncqueryValue(osmoticQuerySo);
syncData.add(osmoticValueVo2s); if(!osmoticValueVo2s.isEmpty()){
syncData.add(osmoticValueVo2s);
}
} }
} else { } else {
//全量同步 //全量同步
osmoticQuerySo.setStationCodes(cds); osmoticQuerySo.setStationCodes(cds);
List<JcskSyR> osmoticValueVo2s = jcskSyRService.getBaseMapper().syncqueryValue(osmoticQuerySo); List<JcskSyR> osmoticValueVo2s = jcskSyRService.getBaseMapper().syncqueryValue(osmoticQuerySo);
syncData.add(osmoticValueVo2s); if(!osmoticValueVo2s.isEmpty()){
syncData.add(osmoticValueVo2s);
}
} }
// 使用DateTimeFormatter替代SimpleDateFormat // 使用DateTimeFormatter替代SimpleDateFormat
@ -435,14 +443,18 @@ public class JcskDataTask {
so.setEnd(new Date()); so.setEnd(new Date());
osmoticQuerySo.setDateTimeRangeSo(so); osmoticQuerySo.setDateTimeRangeSo(so);
List<OsmoticShiftValueVo2> shiftValueVo2s = jcskGnssRService.getBaseMapper().queryValue(osmoticQuerySo); List<OsmoticShiftValueVo2> shiftValueVo2s = jcskGnssRService.getBaseMapper().queryValue(osmoticQuerySo);
syncData.add(shiftValueVo2s); if(!shiftValueVo2s.isEmpty()){
syncData.add(shiftValueVo2s);
}
} }
} else { } else {
//全量同步 //全量同步
osmoticQuerySo.setStationCodes(cds); osmoticQuerySo.setStationCodes(cds);
List<OsmoticShiftValueVo2> shiftValueVo2s = jcskGnssRService.getBaseMapper().queryValue(osmoticQuerySo); List<OsmoticShiftValueVo2> shiftValueVo2s = jcskGnssRService.getBaseMapper().queryValue(osmoticQuerySo);
syncData.add(shiftValueVo2s); if(!shiftValueVo2s.isEmpty()){
syncData.add(shiftValueVo2s);
}
} }
if(syncData.size()>0){ if(syncData.size()>0){