parent
7e4bdbce28
commit
a64b448365
|
|
@ -4,14 +4,12 @@ package com.gunshi.project.hsz.controller;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.hsz.entity.dto.RiceSupportBalanceCaculateDto;
|
||||
import com.gunshi.project.hsz.entity.dto.RiceWaterCaculateDto;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculateIcPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculatePageSo;
|
||||
import com.gunshi.project.hsz.entity.vo.RiceRqWaterCaculateVo;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculateRcPageSo;
|
||||
import com.gunshi.project.hsz.model.IcWaterForecast;
|
||||
import com.gunshi.project.hsz.model.RiceRqWater;
|
||||
import com.gunshi.project.hsz.model.RiceSupportBalance;
|
||||
import com.gunshi.project.hsz.service.IcWaterForecastService;
|
||||
import com.gunshi.project.hsz.service.RiceRqWaterService;
|
||||
import com.gunshi.project.hsz.service.RiceSupportBalanceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
@ -42,7 +40,7 @@ public class RiceSupportBalanceController {
|
|||
}
|
||||
|
||||
@Operation(summary = "计算")
|
||||
@PostMapping("/caculate")
|
||||
@PostMapping("/insert")
|
||||
public R<Boolean> caculate(@RequestBody RiceSupportBalanceCaculateDto dto){
|
||||
riceSupportBalanceService.caculateAndSave(dto);
|
||||
return R.ok(true);
|
||||
|
|
@ -50,14 +48,14 @@ public class RiceSupportBalanceController {
|
|||
|
||||
@Operation(summary = "来水预测-分页查询,供需平衡版")
|
||||
@PostMapping("/icpage")
|
||||
public R<Page<IcWaterForecast>> icPage(@RequestBody RiceSupportBalanceCaculatePageSo pageSo){
|
||||
public R<Page<IcWaterForecast>> icPage(@RequestBody RiceSupportBalanceCaculateIcPageSo pageSo){
|
||||
Page<IcWaterForecast> page = riceSupportBalanceService.icPage(pageSo);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
@Operation(summary = "农业需水-分页查询,供需平衡版")
|
||||
@PostMapping("/rcpage")
|
||||
public R<Page<RiceRqWater>> rcPage(@RequestBody RiceSupportBalanceCaculatePageSo pageSo){
|
||||
public R<Page<RiceRqWater>> rcPage(@RequestBody RiceSupportBalanceCaculateRcPageSo pageSo){
|
||||
Page<RiceRqWater> page = riceSupportBalanceService.rcPage(pageSo);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RiceSupportBalanceCaculateIcPageSo {
|
||||
|
||||
|
||||
private PageSo pageSo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime startTime; // 开始时间
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime endTime; // 结束时间
|
||||
|
||||
private String icplanName; // 计划名称
|
||||
|
||||
private Integer type; // 类型 0 长期 1短期
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -11,8 +12,10 @@ public class RiceSupportBalanceCaculatePageSo {
|
|||
|
||||
private PageSo pageSo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime startTime; // 开始时间
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime endTime; // 结束时间
|
||||
|
||||
private String planName; // 计划名称
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RiceSupportBalanceCaculateRcPageSo {
|
||||
|
||||
|
||||
private PageSo pageSo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime startTime; // 开始时间
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime endTime; // 结束时间
|
||||
|
||||
private String rcplanName; // 计划名称
|
||||
|
||||
private Integer type; // 类型 0 长期 1短期
|
||||
}
|
||||
|
|
@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.gunshi.project.hsz.common.model.StRsvrRReal;
|
||||
import com.gunshi.project.hsz.entity.RiceSupportMidCaculate;
|
||||
import com.gunshi.project.hsz.entity.dto.RiceSupportBalanceCaculateDto;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculateIcPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculatePageSo;
|
||||
import com.gunshi.project.hsz.entity.so.RiceSupportBalanceCaculateRcPageSo;
|
||||
import com.gunshi.project.hsz.entity.vo.TyYearRainfallVo;
|
||||
import com.gunshi.project.hsz.mapper.RiceSupportBalanceMapper;
|
||||
import com.gunshi.project.hsz.model.*;
|
||||
|
|
@ -23,7 +25,6 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -51,12 +52,34 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
|
|||
@Autowired
|
||||
private TyYearRainfallService tyYearRainfallService;//降雨相似年资料
|
||||
|
||||
@Autowired
|
||||
private IcWaterForecastDetailService icWaterForecastDetailService;
|
||||
|
||||
@Autowired
|
||||
private RiceGrowConfigService riceGrowConfigService;
|
||||
|
||||
@Autowired
|
||||
private RiceIrrigationUseService riceIrrigationUseService;
|
||||
|
||||
@Autowired
|
||||
private RiceWaterForecastCycleService riceWaterForecastCycleService;
|
||||
|
||||
@Autowired
|
||||
private RiceWaterForecastMonthService riceWaterForecastMonthService;
|
||||
|
||||
@Autowired
|
||||
private RiceWaterKiService riceWaterKiService;
|
||||
|
||||
public AttResBase getAttResBase(){
|
||||
return attResBaseService.list().get(0);
|
||||
}
|
||||
|
||||
|
||||
public void caculateAndSave(RiceSupportBalanceCaculateDto dto) {
|
||||
|
||||
if(dto.getEndTime().isBefore(dto.getStartTime())){
|
||||
throw new IllegalArgumentException("开始时间必须小于结束时间");
|
||||
}
|
||||
RiceRqWater riceRqWater = riceRqWaterService.queryById(dto.getRqId());
|
||||
IcWaterForecast icWaterForecast = icWaterForecastService.queryById(dto.getIcId());
|
||||
//获取生态每天生态需水量(万m³)
|
||||
|
|
@ -183,8 +206,8 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
|
|||
riceSupportBalance.setStartTime(dto.getStartTime());
|
||||
riceSupportBalance.setEndTime(dto.getEndTime());
|
||||
riceSupportBalance.setCreateTime(LocalDateTime.now());
|
||||
riceSupportBalance.setTotalPlan(totalPlan);//实际供水量
|
||||
riceSupportBalance.setTotalCost(totalNeedWater);//计划供水量
|
||||
// riceSupportBalance.setTotalPlan(totalPlan);//实际供水量
|
||||
// riceSupportBalance.setTotalCost(totalNeedWater);//计划供水量
|
||||
riceSupportBalance.setCreateName(dto.getCreateName());
|
||||
riceSupportBalance.setStatus(0);
|
||||
riceSupportBalance.setPlanName(dto.getPlanName());
|
||||
|
|
@ -271,46 +294,64 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
|
|||
|
||||
if(!saveDetails.isEmpty()){
|
||||
riceSupportBalanceDetailService.saveBatch(saveDetails);
|
||||
log.info("成功保存水稻平衡供水明细,主表ID:{},明细数量:{}",
|
||||
mainId, saveDetails.size());
|
||||
}
|
||||
BigDecimal finalTotalPlan = BigDecimal.ZERO;
|
||||
BigDecimal finalTotalCost = BigDecimal.ZERO;
|
||||
for (RiceSupportBalanceDetail saveDetail : saveDetails) {
|
||||
finalTotalPlan = finalTotalPlan.add(saveDetail.getEcoPlan().add(saveDetail.getIrrigationPlan()));
|
||||
finalTotalCost = finalTotalCost.add(saveDetail.getEcoUse().add(saveDetail.getIrrigationUse()));
|
||||
}
|
||||
riceSupportBalance.setTotalPlan(finalTotalPlan);
|
||||
riceSupportBalance.setTotalCost(finalTotalCost);
|
||||
riceSupportBalance.setStatus(1);
|
||||
updateById(riceSupportBalance);
|
||||
} catch (Exception e) {
|
||||
log.error("保存水稻平衡供水明细失败", e);
|
||||
riceSupportBalance.setStatus(2);
|
||||
riceSupportBalance.setFailReason(e.getMessage());
|
||||
updateById(riceSupportBalance);
|
||||
}
|
||||
}).start();
|
||||
// 主线程立即返回,不等待明细计算完成
|
||||
log.info("水稻平衡供水主表已保存,明细计算正在异步执行");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Page<IcWaterForecast> icPage(RiceSupportBalanceCaculatePageSo pageSo) {
|
||||
public Page<IcWaterForecast> icPage(RiceSupportBalanceCaculateIcPageSo pageSo) {
|
||||
LambdaQueryWrapper<IcWaterForecast> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.le(IcWaterForecast::getStartTime,pageSo.getStartTime());
|
||||
queryWrapper.ge(IcWaterForecast::getEndTime,pageSo.getEndTime());
|
||||
if(pageSo.getType() != null){
|
||||
queryWrapper.eq(IcWaterForecast::getType, pageSo.getType());
|
||||
}
|
||||
if(!StringUtils.isBlank(pageSo.getPlanName())){
|
||||
queryWrapper.like(IcWaterForecast::getPlanName, pageSo.getPlanName());
|
||||
if(!StringUtils.isBlank(pageSo.getIcplanName())){
|
||||
queryWrapper.like(IcWaterForecast::getPlanName, pageSo.getIcplanName());
|
||||
}
|
||||
Page<IcWaterForecast> icWaterForecastPage = icWaterForecastService.getBaseMapper().selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||
for (IcWaterForecast record : icWaterForecastPage.getRecords()) {
|
||||
List<IcWaterForecastDetail> icWaterForecastDetails = icWaterForecastDetailService.listByForecastId(record.getId());
|
||||
record.setDetails(icWaterForecastDetails);
|
||||
}
|
||||
return icWaterForecastPage;
|
||||
}
|
||||
|
||||
public Page<RiceRqWater> rcPage(RiceSupportBalanceCaculatePageSo pageSo) {
|
||||
public Page<RiceRqWater> rcPage(RiceSupportBalanceCaculateRcPageSo pageSo) {
|
||||
List<Integer> yearByRangeDate = LocalDateTimeUtils.getYearByRangeDate(pageSo.getStartTime(), pageSo.getEndTime());
|
||||
LambdaQueryWrapper<RiceRqWater> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(pageSo.getPlanName())){
|
||||
queryWrapper.like(RiceRqWater::getPlanName, pageSo.getPlanName());
|
||||
if(!StringUtils.isBlank(pageSo.getRcplanName())){
|
||||
queryWrapper.like(RiceRqWater::getPlanName, pageSo.getRcplanName());
|
||||
}
|
||||
queryWrapper.in(RiceRqWater::getYear, yearByRangeDate);
|
||||
Page<RiceRqWater> riceRqWaterPage = riceRqWaterService.getBaseMapper().selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||
List<RiceRqWater> records = riceRqWaterPage.getRecords();
|
||||
for (RiceRqWater record : records) {
|
||||
//灌水定额配置
|
||||
record.setRiceWaterKis(riceWaterKiService.selectByRiceWaterId(record.getId()));
|
||||
//水稻生长系数配置
|
||||
record.setRiceGrowConfig(riceGrowConfigService.selectByRiceWaterId(record.getId()));
|
||||
//按月份
|
||||
record.setRiceWaterForecastMonths(riceWaterForecastMonthService.selectByRiceWaterId(record.getId()));
|
||||
//按生长周期
|
||||
record.setRiceWaterForecastCycles(riceWaterForecastCycleService.selectByRiceWaterId(record.getId()));
|
||||
}
|
||||
return riceRqWaterPage;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,23 +43,26 @@ public class SysVisitMenuLogController {
|
|||
// private ProjectCommonService projectCommonService;
|
||||
@Post(path = "/page", summary = "分页查询")
|
||||
public R<Page<SysVisitMenuLog>> page(@RequestBody @Validated VisitMenuLogPageSo dto) {
|
||||
LambdaQueryWrapper<SysVisitMenuLog> queryWrapper = Wrappers.lambdaQuery();
|
||||
// LambdaQueryWrapper<SysVisitMenuLog> queryWrapper = Wrappers.lambdaQuery();
|
||||
//
|
||||
// if (dto.getMenu() != null) {
|
||||
// queryWrapper.like(SysVisitMenuLog::getMenu1, dto.getMenu());
|
||||
// queryWrapper.like(SysVisitMenuLog::getMenu2, dto.getMenu());
|
||||
// queryWrapper.like(SysVisitMenuLog::getMenu3, dto.getMenu());
|
||||
// }
|
||||
|
||||
if (dto.getMenu() != null) {
|
||||
queryWrapper.like(SysVisitMenuLog::getMenu1, dto.getMenu());
|
||||
queryWrapper.like(SysVisitMenuLog::getMenu2, dto.getMenu());
|
||||
queryWrapper.like(SysVisitMenuLog::getMenu3, dto.getMenu());
|
||||
}
|
||||
|
||||
return R.ok(thisMapper.selectPage(dto.getPageSo().toPage(), queryWrapper));
|
||||
return R.ok(thisMapper.pageQuery(dto.getPageSo().toPage(),dto));
|
||||
}
|
||||
|
||||
@Post(path = "/count", summary = "统计查询")
|
||||
public R<List<SysVisitMenuLog>> count(@RequestBody @Validated VisitMenuLogPageSo dto) {
|
||||
|
||||
LambdaQueryWrapper<SysVisitMenuLog> queryWrapper = Wrappers.query(SysVisitMenuLog.class)
|
||||
.select("COUNT(ID) COUNT, menu2, menu1")
|
||||
.select("COUNT(ID) COUNT, menu2, menu1,menu3")
|
||||
.lambda();
|
||||
if(dto.getLoginType() != null){
|
||||
queryWrapper.eq(SysVisitMenuLog::getLoginType, dto.getLoginType());
|
||||
}
|
||||
|
||||
if (dto.getStm() != null) {
|
||||
queryWrapper.ge(SysVisitMenuLog::getCreateTime, dto.getStm());
|
||||
|
|
@ -69,21 +72,10 @@ public class SysVisitMenuLogController {
|
|||
queryWrapper.le(SysVisitMenuLog::getCreateTime, dto.getEtm());
|
||||
}
|
||||
|
||||
queryWrapper.groupBy(SysVisitMenuLog::getMenu2, SysVisitMenuLog::getMenu1);
|
||||
|
||||
queryWrapper.groupBy(SysVisitMenuLog::getMenu2, SysVisitMenuLog::getMenu1,SysVisitMenuLog::getMenu3)
|
||||
.last("ORDER BY COUNT DESC");
|
||||
List<SysVisitMenuLog> list = thisMapper.selectList(queryWrapper);
|
||||
|
||||
|
||||
return R.ok(
|
||||
list
|
||||
.stream()
|
||||
.sorted(
|
||||
Comparator
|
||||
.comparing(SysVisitMenuLog::getCount)
|
||||
.reversed()
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Post(path = "/insert", summary = "添加")
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ public interface SysUserLoginLogMapper extends BaseMapper<SysUserLoginLog> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT su.*,ub.user_name
|
||||
FROM sys_user_login_log su LEFT JOIN uams_user_b ub on su.createId = ub.user_id
|
||||
SELECT su.*,ub.nick_name as userName
|
||||
FROM sys_user_login_log su LEFT JOIN sys_user ub on su.create_id = ub.user_id
|
||||
WHERE su.create_date between #{stm} and #{etm}
|
||||
</script>
|
||||
""")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,23 @@
|
|||
package com.gunshi.project.hsz.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.hsz.system.model.SysVisitMenuLog;
|
||||
import com.gunshi.project.hsz.system.so.VisitMenuLogPageSo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface SysVisitMenuLogMapper extends BaseMapper<SysVisitMenuLog> {
|
||||
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.*,s.nick_name as name from sys_visit_menu_log t
|
||||
left join sys_user s on t.create_id = s.user_id
|
||||
order by t.create_time desc
|
||||
</script>
|
||||
""")
|
||||
Page<SysVisitMenuLog> pageQuery(Page<Object> page, VisitMenuLogPageSo dto);
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.gunshi.project.hsz.system.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
|
@ -26,9 +27,11 @@ public class UserLoginLogPageSo {
|
|||
private String name;
|
||||
|
||||
@Schema(description="开始时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date stm;
|
||||
|
||||
@Schema(description="结束时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date etm;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.gunshi.project.hsz.system.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
|
@ -19,10 +20,12 @@ public class UserLoginLogSo {
|
|||
|
||||
|
||||
@Schema(description="开始时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@NotNull
|
||||
private Date stm;
|
||||
|
||||
@Schema(description="结束时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@NotNull
|
||||
private Date etm;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.gunshi.project.hsz.system.so;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
|
@ -18,7 +19,6 @@ import java.util.Date;
|
|||
@Schema(description = "页面访问记录分页查询条件")
|
||||
public class VisitMenuLogPageSo {
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
|
|
@ -28,10 +28,15 @@ public class VisitMenuLogPageSo {
|
|||
@Schema(description="名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description="登录类型, 0: web, 1:app")
|
||||
private String loginType;
|
||||
|
||||
@Schema(description="开始时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date stm;
|
||||
|
||||
@Schema(description="结束时间 yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date etm;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue