兴利计划
parent
eb97c55199
commit
23fb0a9b3e
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.gunshi.project.hsz.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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.ByLogPageSo;
|
||||||
|
import com.gunshi.project.hsz.entity.so.XlPlanPageSo;
|
||||||
|
import com.gunshi.project.hsz.model.ByLog;
|
||||||
|
import com.gunshi.project.hsz.model.ByLogDetail;
|
||||||
|
import com.gunshi.project.hsz.model.XlPlan;
|
||||||
|
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||||
|
import com.gunshi.project.hsz.service.XlPlanService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/xlPlan")
|
||||||
|
@Tag(name = "兴利计划")
|
||||||
|
public class XlPlanController extends AbstractCommonFileController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private XlPlanService xlPlanService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileAssociationsService fileService;
|
||||||
|
|
||||||
|
@Operation(summary = "新增")
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public R<XlPlan> insert(@Validated(Insert.class) @RequestBody XlPlan dto) {
|
||||||
|
dto.setId(IdWorker.getId());
|
||||||
|
boolean flag = xlPlanService.saveData(dto);
|
||||||
|
if(flag){
|
||||||
|
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||||
|
}
|
||||||
|
return R.ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public R<XlPlan> update(@Validated(Update.class) @RequestBody XlPlan dto) {
|
||||||
|
|
||||||
|
boolean flag = xlPlanService.update(dto);
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
|
||||||
|
}
|
||||||
|
return R.ok(flag ? dto : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
@GetMapping("/del/{id}")
|
||||||
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||||
|
XlPlan byId = xlPlanService.getById(id);
|
||||||
|
if(Objects.isNull(byId)){
|
||||||
|
throw new IllegalArgumentException("该计划不存在");
|
||||||
|
}
|
||||||
|
boolean flag = xlPlanService.removeById(id);
|
||||||
|
if(flag){
|
||||||
|
fileService.deleteFile(getGroupId(),byId.getId().toString());
|
||||||
|
}
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
@PostMapping("/page")
|
||||||
|
public R<Page<XlPlan>> page(@RequestBody XlPlanPageSo pageSo) {
|
||||||
|
Page<XlPlan> res = xlPlanService.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 "xlPlan";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
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 XlPlanPageSo {
|
||||||
|
@NotNull(message = "分页参数不能为空")
|
||||||
|
@Schema(description = "分页参数")
|
||||||
|
private PageSo pageSo;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "计划名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "计划类型")
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.gunshi.project.hsz.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.hsz.model.XlPlan;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface XlPlanMapper extends BaseMapper<XlPlan> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
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.gunshi.core.dateformat.DateFormatString;
|
||||||
|
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.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划表实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("xl_plan")
|
||||||
|
@Schema(description = "兴利计划-实体类")
|
||||||
|
public class XlPlan {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划名称
|
||||||
|
*/
|
||||||
|
@TableField("plan_name")
|
||||||
|
@Schema(description = "计划名称")
|
||||||
|
@NotNull(message = "计划名称不能为空",groups = {Insert.class, Update.class})
|
||||||
|
private String planName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划类型 0月度 1年度
|
||||||
|
*/
|
||||||
|
@TableField("plan_type")
|
||||||
|
@Schema(description = "计划类型 0月度 1 年度")
|
||||||
|
@NotNull(message = "请选择计划类型",groups = {Insert.class, Update.class})
|
||||||
|
private Integer planType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划年份/月份
|
||||||
|
*/
|
||||||
|
@TableField("plan_date")
|
||||||
|
@Schema(description = "计划年份/月份")
|
||||||
|
@NotNull(message = "计划年份/月份请选择",groups = {Insert.class, Update.class})
|
||||||
|
private LocalDateTime planDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 灌溉计划供水量(万)
|
||||||
|
*/
|
||||||
|
@TableField("gg_water")
|
||||||
|
@Schema(description = "灌溉计划供水量(万)")
|
||||||
|
private BigDecimal ggWater;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态计划供水量(万)
|
||||||
|
*/
|
||||||
|
@TableField("st_water")
|
||||||
|
@Schema(description = "生态计划供水量")
|
||||||
|
private BigDecimal stWater;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划开始日期
|
||||||
|
*/
|
||||||
|
@TableField("plan_begin")
|
||||||
|
@Schema(description = "计划开始日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private LocalDateTime planBegin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划结束日期
|
||||||
|
*/
|
||||||
|
@TableField("plan_end")
|
||||||
|
@Schema(description = "计划结束日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private LocalDateTime planEnd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划编制单位
|
||||||
|
*/
|
||||||
|
@TableField("bzdw_plan")
|
||||||
|
@Schema(description = "编制计划单位")
|
||||||
|
private String bzdwPlan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编制日期
|
||||||
|
*/
|
||||||
|
@TableField("bz_date")
|
||||||
|
@Schema(description = "编制日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private LocalDateTime bzDate;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("fill_date")
|
||||||
|
@Schema(description = "填报时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime fillDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 说明
|
||||||
|
*/
|
||||||
|
@TableField("remark")
|
||||||
|
@Schema(description = "说明")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<FileAssociations> files;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
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.XlPlanPageSo;
|
||||||
|
import com.gunshi.project.hsz.mapper.WaterAlarmMapper;
|
||||||
|
import com.gunshi.project.hsz.mapper.XlPlanMapper;
|
||||||
|
import com.gunshi.project.hsz.model.WaterAlarm;
|
||||||
|
import com.gunshi.project.hsz.model.XlPlan;
|
||||||
|
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 XlPlanService extends ServiceImpl<XlPlanMapper, XlPlan> {
|
||||||
|
|
||||||
|
|
||||||
|
public boolean saveData(XlPlan dto) {
|
||||||
|
LambdaQueryWrapper<XlPlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(XlPlan::getPlanName, dto.getPlanName());
|
||||||
|
queryWrapper.eq(XlPlan::getPlanType, dto.getPlanType());
|
||||||
|
queryWrapper.eq(XlPlan::getPlanDate, dto.getPlanDate());
|
||||||
|
XlPlan xlPlan = baseMapper.selectOne(queryWrapper);
|
||||||
|
if(Objects.nonNull(xlPlan)){
|
||||||
|
throw new IllegalArgumentException("该计划已存在,请检查");
|
||||||
|
}
|
||||||
|
save(dto);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(XlPlan dto) {
|
||||||
|
XlPlan byId = getById(dto.getId());
|
||||||
|
if(Objects.isNull(byId)){
|
||||||
|
throw new IllegalArgumentException("该计划不存在,无法删除");
|
||||||
|
}
|
||||||
|
boolean flag = updateById(dto);
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<XlPlan> pageQuery(XlPlanPageSo pageSo) {
|
||||||
|
LambdaQueryWrapper<XlPlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if(!StringUtils.isBlank(pageSo.getName())){
|
||||||
|
queryWrapper.like(XlPlan::getPlanName, pageSo.getName());
|
||||||
|
}
|
||||||
|
if(pageSo.getType() != null){
|
||||||
|
queryWrapper.eq(XlPlan::getPlanType, pageSo.getType());
|
||||||
|
}
|
||||||
|
Page<XlPlan> xlPlanPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||||
|
return xlPlanPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue