Merge branch 'develop_1' into 'develop_master'

Develop 1

See merge request !32
This commit is contained in:
王夏晖
2021-07-15 06:24:04 +00:00
10 changed files with 102 additions and 109 deletions
@@ -86,11 +86,6 @@ public class SarLawsDetailedListController extends BaseController<SarLawsDetaile
String countryArea, String projectName,
String detailedList,
String detailedListName) {
if ("null".equals(countryArea))countryArea=null;
if ("null".equals(projectName))projectName=null;
if ("null".equals(detailedList))detailedList=null;
if ("null".equals(detailedListName))detailedListName=null;
if (StringUtils.isNotEmpty(sortKey)) {
IPage<SarLawsDetailedList> publicList = sarLawsDetailedListService.AllSelectD(page, pageSize, sortKey,
countryArea, projectName, detailedList, detailedListName);
@@ -3,11 +3,17 @@ 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.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.GetExcelDto;
import com.adc.da.slrs.sarStandIdea.service.Impl.SarPublicIdeaAllServiceImpl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,6 +24,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
@@ -34,6 +44,8 @@ public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll>
@Autowired
private SarPublicIdeaAllServiceImpl sarPublicIdeaAllImpl;
@Autowired
private SarPublicIdeaAllDao sarPublicIdeaAllDao;
@ApiOperation(value = "查询全部意见")
@@ -59,7 +71,6 @@ public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll>
return Result.success("200",src);
}
@ApiOperation(value = "修改意见")
@PostMapping("/updateStand")
public ResponseMessage updateStand(SarPublicIdeaAll sarPublicIdeaAll,String autUserId){
@@ -67,14 +78,42 @@ public class SarPublicIdeaAllController extends BaseController<SarPublicIdeaAll>
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);
}
public void getAllStand(HttpServletResponse response,String cid){
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("意见详情", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<SarPublicIdeaAll> data=new ArrayList<>();
if (!StringUtils.isEmpty(cid)){
QueryWrapper<SarPublicIdeaAll> wrapper = new QueryWrapper<>();
wrapper.eq(SarPublicIdeaAll.CID,cid);
data=sarPublicIdeaAllDao.selectList(wrapper);
}
List<GetExcelDto> standExcel=new ArrayList<>();
for (SarPublicIdeaAll sarPublicIdeaAll:data){
GetExcelDto getExcelDto=GetExcelDto.builder()
.partCode(sarPublicIdeaAll.getPartCode())
.content(sarPublicIdeaAll.getContent())
.userName(sarPublicIdeaAll.getUserName())
.deptName(sarPublicIdeaAll.getDeptName())
.build();
standExcel.add(getExcelDto);
}
EasyExcel.write(response.getOutputStream(),GetExcelDto.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(standExcel);
} catch (Exception e) {
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
try {
response.getWriter().println(JSON.toJSONString(Result.error()));
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
@@ -0,0 +1,35 @@
package com.adc.da.slrs.sarStandIdea.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* //用于导出
*
* @author ZhangZhiYuan
* @date 2021-07-14
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@HeadRowHeight(20)
@ColumnWidth(15)
public class GetExcelDto {
@ExcelProperty("章节编号")
private String partCode;
@ExcelProperty("内容")
private String content;
@ExcelProperty("提出人")
private String userName;
@ExcelProperty("所在部门")
private String deptName;
}
@@ -25,6 +25,4 @@ public interface ISarPublicIdeaAllService extends IService<SarPublicIdeaAll> {
String updateById(SarPublicIdeaAll sarPublicIdeaAll, String autUserid);
String delete(DelStandDto delStandDto);
String del(String id);
String stuListExcel(HttpServletResponse response,String cid);
}
@@ -88,74 +88,4 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
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).getUserName());
row.createCell(5).setCellValue(data.get(i).getDeptName());
}
//设置单元格宽度自适应,在此基础上把宽度调至1.5倍
for (int i = 0; i < title.length; i++) {
stuSheet.autoSizeColumn(i, true);
stuSheet.setColumnWidth(i, stuSheet.getColumnWidth(i) * 15 / 10);
}
response.setContentType("application/octet-stream; charset=iso-8859-1");
StringBuffer contentDisposition = new StringBuffer("attachment; filename=\"");
String fileName = new String("Reply-content.xlsx".getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
contentDisposition.append(fileName).append("\"");
response.setHeader("Content-disposition", contentDisposition.toString());
ServletOutputStream out = null;
try {
out = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
wb.write(out);
} catch (IOException e) {
e.printStackTrace();
}
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return "下载成功";
}
}
@@ -72,7 +72,6 @@ public class SarStandProjectLibraryController extends BaseController<SarStandPro
return Result.success("200",list);
}
@GetMapping("/queryProjectManager")
@ApiOperation("查询产品线项目经理")
public ResponseMessage queryProjectManager(@RequestParam(defaultValue = "1", value = "current")int current, @RequestParam(defaultValue = "10", value = "PageSize") int pageSize){
@@ -83,18 +82,12 @@ public class SarStandProjectLibraryController extends BaseController<SarStandPro
productLineDto p = new productLineDto();
p.setProductLine(sarStandProjectLibrary.getProductLine());
p.setUName(sarStandProjectLibrary.getUName());
p.setProjectManager(sarStandProjectLibrary.getProjectManager());
List<SarStandProjectLibrary> list2 = sarStandProjectLibraryService.queryByProductLine(sarStandProjectLibrary.getProductLine());
p.setSarStandProjectLibraries(list2);
listTemp.add(p);
}
IPage<productLineDto> iPage = new Page<>();
iPage.setRecords(listTemp);
iPage.setCurrent(list1.getCurrent());
iPage.setSize(list1.getSize());
iPage.setTotal(list1.getTotal());
iPage.setPages(list1.getPages());
return Result.success("200",iPage);
return Result.success("200",listTemp);
}
}
@@ -16,6 +16,6 @@ import java.util.List;
* @since 2021-06-15
*/
public interface SarStandProjectLibraryDao extends BaseMapper<SarStandProjectLibrary> {
List<SarStandProjectLibrary> queryProjectManagerPage(@Param("current") int current, @Param("pageSize") int pageSize);
// List<SarStandProjectLibrary> queryProjectManagerPage(@Param("current") int current, @Param("pageSize") int pageSize);
}
@@ -11,5 +11,7 @@ public class productLineDto {
private String productLine;
private String projectManager;
private List<SarStandProjectLibrary> sarStandProjectLibraries;
}
@@ -4,7 +4,6 @@ import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlPr
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary;
import com.adc.da.slrs.sarStandProjectLibrary.dao.SarStandProjectLibraryDao;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibraryDto;
import com.adc.da.slrs.sarStandProjectLibrary.entity.productLineDto;
import com.adc.da.slrs.sarStandProjectLibrary.service.SarStandProjectLibraryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -128,11 +127,13 @@ public class SarStandProjectLibraryServiceImpl extends ServiceImpl<SarStandProje
@Override
public IPage<SarStandProjectLibrary> queryProjectManager(int current, int pageSize) {
QueryWrapper<SarStandProjectLibrary> wrapper = new QueryWrapper<>();
wrapper.groupBy("product_line");
IPage<SarStandProjectLibrary> list = sarStandProjectLibraryDao.selectPage(new Page<>(current,pageSize),wrapper);
List<SarStandProjectLibrary> libraryIPage=sarStandProjectLibraryDao.queryProjectManagerPage((current-1)*pageSize,current*pageSize);
list.setRecords(libraryIPage);
return list;
wrapper.select("product_line","project_manager","uName");
wrapper.last("inner join ts_user t on sar_stand_project_library.project_manager=t.usid group by sar_stand_project_library.product_line");
Page<SarStandProjectLibrary> page = new Page<>(current, pageSize);
IPage<SarStandProjectLibrary> userIPage = sarStandProjectLibraryDao.selectPage(page, wrapper);
System.out.println("总条数"+userIPage.getTotal());
System.out.println("总页数"+userIPage.getPages());
return userIPage;
}
@Override
@@ -3,12 +3,12 @@
<mapper namespace="com.adc.da.slrs.sarStandProjectLibrary.dao.SarStandProjectLibraryDao">
<select id="queryProjectManagerPage" resultType="com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary">
select s.product_line,t.UNAME as uName
from sar_stand_project_library s
INNER JOIN ts_user t
ON s.project_manager=t.USID
GROUP BY s.product_line
limit #{current},#{pageSize}
</select>
<!-- <select id="queryProjectManagerPage" resultType="com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary">-->
<!-- select s.product_line,t.UNAME as uName-->
<!-- from sar_stand_project_library s-->
<!-- INNER JOIN ts_user t-->
<!-- ON s.project_manager=t.USID-->
<!-- GROUP BY s.product_line-->
<!-- limit #{current},#{pageSize}-->
<!-- </select>-->
</mapper>