add:标准公开征求意见

This commit is contained in:
zzy
2021-06-05 15:34:43 +08:00
parent 99c2dd95ce
commit 9ce1094070
19 changed files with 433 additions and 292 deletions
@@ -0,0 +1,79 @@
package com.adc.da.slrs.sarStandIdea.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandIdea.entity.DelStandDto;
import com.adc.da.slrs.sarStandIdea.entity.DetAllStandDto;
import com.adc.da.slrs.sarStandIdea.service.Impl.SarPublicIdeaAllServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdeaAll;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@RestController
@Api(description = "|SarPublicIdeaAll|")
@RequestMapping("/${restPath}/slrs/sar-public-idea-all")
public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll> {
@Autowired
private SarPublicIdeaAllServiceImpl sarPublicIdeaAllImpl;
@ApiOperation(value = "查询全部意见")
@GetMapping("/getAllStand")
public ResponseMessage getAllStand(DetAllStandDto detAllStandDto){
IPage<SarPublicIdeaAll> publicList =sarPublicIdeaAllImpl.selectAll(detAllStandDto);
return Result.success("200",publicList);
}
@ApiOperation(value = "增加意见")
@GetMapping("/insetStand")
public ResponseMessage addAllStand(SarPublicIdeaAll sar){
String src=sarPublicIdeaAllImpl.add(sar);
return Result.success("200",src);
}
@ApiOperation(value = "删除意见")
@GetMapping("/deleteStand")
public ResponseMessage deleteStand(DelStandDto delStandDto){
String src=sarPublicIdeaAllImpl.delete(delStandDto);
return Result.success("200",src);
}
@ApiOperation(value = "修改意见")
@GetMapping("/updateStand")
public ResponseMessage updateStand(SarPublicIdeaAll sarPublicIdeaAll,String autUserId){
String src=sarPublicIdeaAllImpl.updateById(sarPublicIdeaAll,autUserId);
return Result.success("200",src);
}
@ApiOperation(value = "导出全部意见")
@GetMapping("/tuallStand")
public ResponseMessage getAllStand(HttpServletResponse response,String cid){
String src=sarPublicIdeaAllImpl.stuListExcel(response,cid);
return Result.success("200",src);
}
}
@@ -0,0 +1,47 @@
package com.adc.da.slrs.sarStandIdea.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandIdea.entity.SeByoDto;
import com.adc.da.slrs.sarStandIdea.service.Impl.SarPublicIdeaServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdea;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
/**
* <p>
* 前端控制器
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@RestController
@Api(description = "|SarPublicIdea|")
@RequestMapping("/${restPath}/slrs/sar-public-idea")
public class SarPublicIdeaController extends BaseController<SarPublicIdea> {
@Autowired
private SarPublicIdeaServiceImpl sarPublicIdeaService;
@ApiOperation(value = "分页查询")
@GetMapping("/SelectAllPage")
public ResponseMessage selectAllPage(@RequestParam(defaultValue="1")Integer page,@RequestParam(defaultValue="10")Integer size){
IPage<SarPublicIdea> publicList =sarPublicIdeaService.selectAllP(page,size);
return Result.success(publicList);
}
@ApiOperation(value = "动态查询")
@GetMapping("/SelectByo")
public ResponseMessage selectByDynamic(SeByoDto seByoDto){
IPage<SarPublicIdea> publicList =sarPublicIdeaService.selectAllDynamic(seByoDto);
return Result.success(publicList);
}
}
@@ -0,0 +1,18 @@
package com.adc.da.slrs.sarStandIdea.dao;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdeaAll;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Mapper
public interface SarPublicIdeaAllDao extends BaseMapper<SarPublicIdeaAll> {
}
@@ -0,0 +1,19 @@
package com.adc.da.slrs.sarStandIdea.dao;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdea;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Mapper
public interface SarPublicIdeaDao extends BaseMapper<SarPublicIdea> {
}
@@ -0,0 +1,31 @@
package com.adc.da.slrs.sarStandIdea.entity;
public class DelStandDto {
private String id;
private String userId;
private String autUserId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getAutUserId() {
return autUserId;
}
public void setAutUserId(String autUserId) {
this.autUserId = autUserId;
}
}
@@ -0,0 +1,40 @@
package com.adc.da.slrs.sarStandIdea.entity;
public class DetAllStandDto {
Integer page;
Integer size;
String cid;
String userId;
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getCid() {
return cid;
}
public void setCid(String cid) {
this.cid = cid;
}
}
@@ -0,0 +1,61 @@
package com.adc.da.slrs.sarStandIdea.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDate;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sar_public_idea")
@ApiModel(value="SarPublicIdea对象", description="")
public class SarPublicIdea extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId("id")
private String id;
@TableField("category")
private String category;
@TableField("cid")
private String cid;
@TableField("cname")
private String cname;
@TableField("start_time")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date startTime;
@TableField("end_time")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date endTime;
@TableField("category_flag")
private String categoryFlag;
}
@@ -0,0 +1,45 @@
package com.adc.da.slrs.sarStandIdea.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sar_public_idea_all")
@ApiModel(value="SarPublicIdeaAll对象", description="")
public class SarPublicIdeaAll extends BaseEntity {
@TableId
private String id;
@TableField("cid")
private String cid;
@TableField("part_code")
private String partCode;
@TableField("content")
private String content;
@TableField("user_id")
private String userId;
public static final String CID = "cid";
}
@@ -0,0 +1,59 @@
package com.adc.da.slrs.sarStandIdea.entity;
public class SeByoDto {
Integer page;
Integer size;
String category;
String cname;
String startTime;
String endTime;
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}
@@ -0,0 +1,30 @@
package com.adc.da.slrs.sarStandIdea.service;
import com.adc.da.slrs.sarStandIdea.entity.DelStandDto;
import com.adc.da.slrs.sarStandIdea.entity.DetAllStandDto;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdeaAll;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
public interface ISarPublicIdeaAllService extends IService<SarPublicIdeaAll> {
IPage<SarPublicIdeaAll> selectAll(DetAllStandDto detAllStandDto);
String add(SarPublicIdeaAll sarPublicIdeaAll);
String updateById(SarPublicIdeaAll sarPublicIdeaAll, String autUseerid);
String delete(DelStandDto delStandDto);
String del(String id);
String stuListExcel(HttpServletResponse response,String cid);
}
@@ -0,0 +1,23 @@
package com.adc.da.slrs.sarStandIdea.service;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdea;
import com.adc.da.slrs.sarStandIdea.entity.SeByoDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
public interface ISarPublicIdeaService extends IService<SarPublicIdea> {
String add(SarPublicIdea sarPublicIdea);
IPage<SarPublicIdea> selectAllP(Integer page, Integer size);
IPage<SarPublicIdea> selectAllDynamic(SeByoDto seByoDto);
}
@@ -0,0 +1,208 @@
package com.adc.da.slrs.sarStandIdea.service.Impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.adc.da.slrs.sarStandIdea.dao.SarPublicIdeaAllDao;
import com.adc.da.slrs.sarStandIdea.entity.DelStandDto;
import com.adc.da.slrs.sarStandIdea.entity.DetAllStandDto;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdeaAll;
import com.adc.da.slrs.sarStandIdea.service.ISarPublicIdeaAllService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Service
public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao, SarPublicIdeaAll> implements ISarPublicIdeaAllService {
@Autowired
private SarPublicIdeaAllDao sarPublicIdeaAllDao;
@Override
public IPage<SarPublicIdeaAll> selectAll(DetAllStandDto detAllStandDto){
QueryWrapper<SarPublicIdeaAll> wrapper = new QueryWrapper<>();
wrapper.eq("CID",detAllStandDto.getCid());
Page<SarPublicIdeaAll> page = new Page<>(detAllStandDto.getPage(),detAllStandDto.getSize());
IPage<SarPublicIdeaAll> userIPage = sarPublicIdeaAllDao.selectPage(page, wrapper);
System.out.println("总条数"+userIPage.getTotal());
System.out.println("总页数"+userIPage.getPages());
return userIPage;
}
@Override
public String add(SarPublicIdeaAll sar) {
if (!StringUtils.isBlank(sar.getId())) {
Snowflake snowflake = IdUtil.createSnowflake(1, 1);
sar.setId(String.valueOf(snowflake.nextId()));
sarPublicIdeaAllDao.insert(sar);
return "增加成功";
}
return "增加失败";
}
@Override
public String updateById(SarPublicIdeaAll sar, String autUseerid) {
if(sar.getUserId().equals(autUseerid)){
sarPublicIdeaAllDao.updateById(sar);
return "修改成功";
}else {
return "修改失败";
}
}
@Override
public String delete(DelStandDto delStandDto) {
if (delStandDto.getUserId().equals(delStandDto.getAutUserId())){
return del(delStandDto.getId());
}else {
return "删除失败,不能删除别人的意见";
}
}
@Override
public String del(String id) {
sarPublicIdeaAllDao.deleteById(id);
return "删除成功";
}
@Override
public String stuListExcel(HttpServletResponse response,String cid) {
QueryWrapper<SarPublicIdeaAll> wrapper = new QueryWrapper<>();
wrapper.eq(SarPublicIdeaAll.CID,cid);
List<SarPublicIdeaAll> data=sarPublicIdeaAllDao.selectList(wrapper);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd hhmmss");
Workbook wb = new XSSFWorkbook();
//标题行抽出字段
String[] title = {"", "标准或政策编号","章节编号", "内容","提出人"};
//设置sheet名称,并创建新的sheet对象
String sheetName = "意见信息一览";
Sheet stuSheet = wb.createSheet(sheetName);
//获取表头行
Row titleRow = stuSheet.createRow(0);
//创建单元格,设置style居中,字体,单元格大小等
CellStyle style = wb.createCellStyle();
Cell cell;
//把已经写好的标题行写入excel文件中
for (int i = 1; i < title.length; i++) {
cell = titleRow.createCell(i);
cell.setCellValue(title[i]);
cell.setCellStyle(style);
}
//把从数据库中取得的数据一一写入excel文件中
Row row = null;
for (int i = 0; i < data.size(); i++) {
//创建list.size()行数据
row = stuSheet.createRow(i + 1);
//把值一一写进单元格里
//设置第一列为自动递增的序号
row.createCell(0).setCellValue(i + 1);
row.createCell(1).setCellValue(data.get(i).getCid());
row.createCell(2).setCellValue(data.get(i).getPartCode());
row.createCell(3).setCellValue(data.get(i).getContent());
row.createCell(4).setCellValue(data.get(i).getUserId());
}
//设置单元格宽度自适应,在此基础上把宽度调至1.5倍
for (int i = 0; i < title.length; i++) {
stuSheet.autoSizeColumn(i, true);
stuSheet.setColumnWidth(i, stuSheet.getColumnWidth(i) * 15 / 10);
}
//获取配置文件中保存对应excel文件的路径,本地也可以直接写成Fexcel/stuInfoExcel路径
String folderPath = "D:/";
//设置文件名
String fileName = sdf1.format(new Date()) + sheetName + ".xlsx";
String savePath = folderPath + File.separator + fileName;
OutputStream fileOut = null;
try {
fileOut = new FileOutputStream(savePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
wb.write(fileOut);
} catch (IOException e) {
e.printStackTrace();
}
try {
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
response.setContentType("application/vnd..ms-excel");
File file = new File(folderPath, fileName);
if (file.exists()) {
response.setContentType("application/x-download;charset=utf-8");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
OutputStream outputStream = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
outputStream.write(buffer, 0, i);
i = bis.read(buffer);
}
file.delete();
return "下载成功";
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
file.delete();
return "下载失败";
}
}
@@ -0,0 +1,104 @@
package com.adc.da.slrs.sarStandIdea.service.Impl;
import com.adc.da.slrs.sarStandIdea.dao.SarPublicIdeaDao;
import com.adc.da.slrs.sarStandIdea.entity.SarPublicIdea;
import com.adc.da.slrs.sarStandIdea.entity.SeByoDto;
import com.adc.da.slrs.sarStandIdea.service.ISarPublicIdeaService;
import com.adc.da.util.UUIDUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* <p>
* 服务实现类
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
@Service("PublicIdeaStandEOService")
public class SarPublicIdeaServiceImpl extends ServiceImpl<SarPublicIdeaDao, SarPublicIdea> implements ISarPublicIdeaService {
@Autowired
private SarPublicIdeaDao sarPublicIdeaDao;
@Override
public String add(SarPublicIdea sarPublicIdea) {
if (!sarPublicIdea.getId().isEmpty()){
sarPublicIdea.setId(UUIDUtils.randomUUID10());
sarPublicIdeaDao.insert(sarPublicIdea);
return "增加成功";
}
return "增加失败";
}
@Override
public IPage<SarPublicIdea> selectAllP(Integer p, Integer size) {
QueryWrapper<SarPublicIdea> wrapper = new QueryWrapper<>();
Page<SarPublicIdea> page = new Page<>(p, size);
IPage<SarPublicIdea> userIPage = sarPublicIdeaDao.selectPage(page, wrapper);
System.out.println("总条数"+userIPage.getTotal());
System.out.println("总页数"+userIPage.getPages());
return userIPage;
}
/**
*
* @param seByoDto
* @return
*/
@Override
public IPage<SarPublicIdea> selectAllDynamic(SeByoDto seByoDto) {
SarPublicIdea sar = new SarPublicIdea();
sar.setCategory(seByoDto.getCategory());
sar.setCname(seByoDto.getCname());
SimpleDateFormat formater = new SimpleDateFormat();
formater.applyPattern("yyyy-MM-dd");
try {
if (seByoDto.getStartTime()!=null){
sar.setStartTime(formater.parse(seByoDto.getStartTime()));
}
if (seByoDto.getEndTime()!=null){
sar.setEndTime(formater.parse(seByoDto.getEndTime()));
}
} catch (ParseException e) {
e.printStackTrace();
}
QueryWrapper<SarPublicIdea> wrapper = new QueryWrapper<>();
if (sar.getCategory()!=null&&sar.getCategory().length()!=0){
wrapper.like("category",sar.getCategory());
}
if (sar.getCname()!=null&&sar.getCname().length()!=0){
wrapper.like("cname",sar.getCname());
}
if (sar.getStartTime()!=null){
wrapper.le("start_time",sar.getStartTime());
}
if (sar.getEndTime()!=null){
wrapper.gt("end_time",sar.getEndTime());
}
// list.eq(StringUtils.isNotEmpty(sar.getCategory()),"category",sar.getCategory())
// .like(StringUtils.isNotEmpty(sar.getCname()),"cname",sar.getCname())
// .gt(sar.getStartTime()!=null,"start_time",sar.getStartTime())
// .le(sar.getEndTime()!=null,"end_time",sar.getEndTime());
Page<SarPublicIdea> page = new Page<>(seByoDto.getPage(), seByoDto.getSize());
IPage<SarPublicIdea> userIPage = sarPublicIdeaDao.selectPage(page, wrapper);
System.out.println("总条数"+userIPage.getTotal());
System.out.println("总页数"+userIPage.getPages());
return userIPage;
}
}