水量调度
parent
bc5eeff638
commit
ce8a24a72e
|
|
@ -0,0 +1,110 @@
|
|||
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.project.hsz.entity.so.WaterDispatchPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.XlPlanPageSo;
|
||||
import com.gunshi.project.hsz.model.IaCDanad;
|
||||
import com.gunshi.project.hsz.model.WaterDispatch;
|
||||
import com.gunshi.project.hsz.model.XlPlan;
|
||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||
import com.gunshi.project.hsz.service.WaterDispatchService;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
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 org.apache.commons.collections4.CollectionUtils;
|
||||
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.Objects;
|
||||
|
||||
@Tag(name = "水量调度")
|
||||
@RestController
|
||||
@RequestMapping(value="/waterDis")
|
||||
public class WaterDispatchController extends AbstractCommonFileController {
|
||||
|
||||
@Autowired
|
||||
private WaterDispatchService waterDispatchService;
|
||||
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<WaterDispatch> insert(@Validated(Insert.class) @RequestBody WaterDispatch dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean flag = waterDispatchService.saveData(dto);
|
||||
if(flag){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "下发")
|
||||
@GetMapping("/distribute/{id}")
|
||||
public R<Boolean> distribute(@PathVariable("id") String id) {
|
||||
WaterDispatch byId = waterDispatchService.getById(id);
|
||||
if(byId == null){
|
||||
throw new IllegalArgumentException("抱歉,该调度不存在,无法下发");
|
||||
}
|
||||
byId.setExeStatus(2);
|
||||
boolean flag = waterDispatchService.updateById(byId);
|
||||
return R.ok(flag);
|
||||
}
|
||||
|
||||
@Operation(summary = "反馈")
|
||||
@PostMapping("feedback")
|
||||
public R<WaterDispatch> feedback(@Validated(Update.class) @RequestBody WaterDispatch dto) {
|
||||
boolean flag = waterDispatchService.feedBack(dto);
|
||||
if(flag){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新")
|
||||
@PostMapping("/update")
|
||||
public R<WaterDispatch> update(@Validated(Update.class) @RequestBody WaterDispatch dto) {
|
||||
boolean flag = waterDispatchService.update(dto);
|
||||
if(flag){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
WaterDispatch byId = waterDispatchService.getById(id);
|
||||
if(Objects.isNull(byId)){
|
||||
throw new IllegalArgumentException("该计划不存在");
|
||||
}
|
||||
boolean flag = waterDispatchService.removeById(id);
|
||||
if(flag){
|
||||
fileService.deleteFile(getGroupId(),byId.getId().toString());
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
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())
|
||||
));
|
||||
}
|
||||
return R.ok(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "waterDispatch";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterDispatchPageSo {
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "调度名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "执行状态")
|
||||
private Integer status;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.WaterDispatch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface WaterDispatchMapper extends BaseMapper<WaterDispatch> {
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
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.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调度指令-实体类
|
||||
*/
|
||||
@Data
|
||||
@TableName("water_dispatch")
|
||||
@Schema(description = "调度指令-实体类")
|
||||
public class WaterDispatch {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId("id")
|
||||
@Schema(description = "主键ID")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "是否下发 0 是 1 否")
|
||||
private Integer isDistribute;
|
||||
|
||||
/**
|
||||
* 调度指令名称
|
||||
*/
|
||||
@TableField("name")
|
||||
@Schema(description = "调度指令名称")
|
||||
@NotNull(message = "调度指令名称不能为空", groups = {Insert.class, Update.class})
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 调度开始时间
|
||||
*/
|
||||
@TableField("dis_start")
|
||||
@Schema(description = "调度开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@NotNull(message = "调度开始时间不能为空", groups = {Insert.class, Update.class})
|
||||
private Date disStart;
|
||||
|
||||
/**
|
||||
* 调度结束时间
|
||||
*/
|
||||
@TableField("dis_end")
|
||||
@Schema(description = "调度结束时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@NotNull(message = "调度结束时间不能为空", groups = {Insert.class, Update.class})
|
||||
private Date disEnd;
|
||||
|
||||
/**
|
||||
* 调度详细
|
||||
*/
|
||||
@TableField("dis_detial")
|
||||
@Schema(description = "调度详细")
|
||||
private String disDetial;
|
||||
|
||||
/**
|
||||
* 执行人员id
|
||||
*/
|
||||
@TableField("exe_person_id")
|
||||
@Schema(description = "执行人员id")
|
||||
private String exePersonId;
|
||||
|
||||
/**
|
||||
* 执行人员名称
|
||||
*/
|
||||
@TableField("exe_person_name")
|
||||
@Schema(description = "执行人员名称")
|
||||
private String exePersonName;
|
||||
|
||||
/**
|
||||
* 执行状态 0完成 1待下发 2执行中
|
||||
*/
|
||||
@TableField("exe_status")
|
||||
@Schema(description = "执行状态 0完成 1待下发 2执行中")
|
||||
private Integer exeStatus;
|
||||
|
||||
/**
|
||||
* 填报时间
|
||||
*/
|
||||
@TableField("fill_time")
|
||||
@Schema(description = "填报时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date fillTime;
|
||||
|
||||
/**
|
||||
* 执行结果反馈
|
||||
*/
|
||||
@TableField("res_fb")
|
||||
@Schema(description = "执行结果反馈")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date resFb;
|
||||
|
||||
/**
|
||||
* 是否完成 0是 1否
|
||||
*/
|
||||
@TableField("is_compelete")
|
||||
@Schema(description = "是否完成 0是 1否")
|
||||
private Integer isCompelete;
|
||||
|
||||
/**
|
||||
* 文件关联列表(非数据库字段)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "文件列表")
|
||||
private List<FileAssociations> files;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.WaterDispatchPageSo;
|
||||
import com.gunshi.project.hsz.mapper.WaterDispatchMapper;
|
||||
import com.gunshi.project.hsz.model.WaterDispatch;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class WaterDispatchService extends ServiceImpl<WaterDispatchMapper, WaterDispatch> {
|
||||
public boolean saveData(WaterDispatch dto) {
|
||||
LambdaQueryWrapper<WaterDispatch> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WaterDispatch::getName, dto.getName());
|
||||
WaterDispatch one = getOne(queryWrapper);
|
||||
if(Objects.nonNull(one)){
|
||||
throw new IllegalArgumentException("该调度已存在");
|
||||
}
|
||||
if(dto.getIsDistribute() == 0){//如果选择下发
|
||||
dto.setExeStatus(2);//状态改为下发中
|
||||
}else{
|
||||
dto.setExeStatus(1);//否则为待下发
|
||||
}
|
||||
save(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean feedBack(WaterDispatch dto) {
|
||||
WaterDispatch byId = getById(dto.getId());
|
||||
if(byId == null){
|
||||
throw new IllegalArgumentException("抱歉,该调度不存在");
|
||||
}
|
||||
if(dto.getIsCompelete() == 0){
|
||||
dto.setExeStatus(0);
|
||||
}
|
||||
updateById(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean update(WaterDispatch dto) {
|
||||
WaterDispatch byId = getById(dto.getId());
|
||||
if(byId == null){
|
||||
throw new IllegalArgumentException("抱歉,该调度不存在");
|
||||
}
|
||||
updateById(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Page<WaterDispatch> pageQuery(WaterDispatchPageSo pageSo) {
|
||||
LambdaQueryWrapper<WaterDispatch> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(pageSo.getName())){
|
||||
queryWrapper.like(WaterDispatch::getName, pageSo.getName());
|
||||
}
|
||||
if(pageSo.getStatus() != null){
|
||||
queryWrapper.eq(WaterDispatch::getExeStatus, pageSo.getStatus());
|
||||
}
|
||||
Page<WaterDispatch> waterDispatchPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||
return waterDispatchPage;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue