重点问题事业部导出和关闭接口
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
package com.adc.da.slrs.ImportExcelDatas.comment;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.Year;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class Analysis {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Contrast.class);
|
||||
|
||||
public void run(MultipartFile file, MultipartFile sort) throws IOException {
|
||||
|
||||
InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
HashSet<String> sortSet = getSet(sort);
|
||||
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(1)!=null){
|
||||
//获取表1的标准号
|
||||
String value = row.getCell(1).toString().trim();
|
||||
Cell sortCell = row.createCell(11);
|
||||
Cell sortNumber = row.createCell(12);
|
||||
Cell sortYear = row.createCell(13);
|
||||
|
||||
sortCell.setCellType(CellType.STRING);
|
||||
sortNumber.setCellType(CellType.STRING);
|
||||
sortYear.setCellType(CellType.STRING);
|
||||
|
||||
List<String> collect = sortSet.stream()
|
||||
.filter(item ->{
|
||||
int length = item.length();
|
||||
if (value.length()>length){
|
||||
return value.substring(0, length).contains(item.trim());
|
||||
}else return false;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//对比在表2中是否存在
|
||||
if (collect.size()==1){
|
||||
|
||||
String sortStr = collect.get(0);
|
||||
int length = sortStr.length();
|
||||
logger.info("*");
|
||||
// Pattern pattern = Pattern.compile("^\\S*\\s\\S*[\\u2014\\u002d\\s]\\d{4}$");
|
||||
// pattern.matcher(standId).matches()
|
||||
if (value.length()>=length+5){
|
||||
sortCell.setCellValue(collect.get(0));
|
||||
sortNumber.setCellValue(value.substring(length,value.length()-5));
|
||||
sortYear.setCellValue(value.substring(value.length()-4));
|
||||
}
|
||||
}else if (collect.size()>1){
|
||||
String maxLenSort="";
|
||||
for (String s : collect) {
|
||||
if (s.length()>maxLenSort.length()){
|
||||
maxLenSort=s;
|
||||
}
|
||||
}
|
||||
|
||||
int length = maxLenSort.length();
|
||||
|
||||
if (value.length()>=length+5){
|
||||
logger.info("+");
|
||||
|
||||
|
||||
sortCell.setCellValue(maxLenSort);
|
||||
sortNumber.setCellValue(value.substring(length,value.length()-5));
|
||||
sortYear.setCellValue(value.substring(value.length()-4));
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.info("-");
|
||||
|
||||
sortCell.setCellValue("-");
|
||||
sortNumber.setCellValue("-");
|
||||
sortYear.setCellValue("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\拆分标准号-海外.xlsx");
|
||||
FileOutputStream os = new FileOutputStream(result);
|
||||
workbook.write(os);
|
||||
// HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
private HashSet<String> getSet(MultipartFile file) throws IOException {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// int lastNum = sheet.getLastRowNum();
|
||||
|
||||
HashSet<String> stringHashSet= new HashSet<>();
|
||||
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(0)!=null){
|
||||
stringHashSet.add(row.getCell(0).toString().trim());
|
||||
}
|
||||
}
|
||||
|
||||
return stringHashSet;
|
||||
}
|
||||
|
||||
}
|
||||
+61
-11
@@ -1,21 +1,24 @@
|
||||
package com.adc.da.slrs.sarStandUnqualified.controller;
|
||||
|
||||
import com.adc.da.base.page.Pager;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
import com.adc.da.http.PageInfo;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssue;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssueVo;
|
||||
import com.adc.da.slrs.sarStandUnqualified.service.IBusinessDeptIssueService;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,24 +34,24 @@ public class BusinessDeptIssueController extends BaseController {
|
||||
|
||||
@PutMapping()
|
||||
@ApiOperation("新增事业部重点问题")
|
||||
public ResponseMessage addIssueTrack(@RequestBody BusinessDeptIssue issue){
|
||||
boolean b = iBusinessDeptIssueService.addBussDeptIssue(issue);
|
||||
public ResponseMessage addBussDeptIssue(@RequestBody BusinessDeptIssue issue){
|
||||
boolean b = iBusinessDeptIssueService.addBusinessDeptIssue(issue);
|
||||
return Result.success(b);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除事业部重点问题")
|
||||
public ResponseMessage removeIssueTrack(@RequestParam(value="selectedString") String idList){
|
||||
public ResponseMessage removeBussDeptIssue(@RequestParam(value="selectedString") String idList){
|
||||
List<String> stringList = Arrays.asList(idList.split(","));
|
||||
boolean b = iBusinessDeptIssueService.removeBussDeptIssue(stringList);
|
||||
boolean b = iBusinessDeptIssueService.removeBusinessDeptIssue(stringList);
|
||||
return Result.success(b);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询事业部重点问题")
|
||||
public ResponseMessage<IPage<BusinessDeptIssue>> getIssueTrack(@RequestParam() BusinessDeptIssueVo pageVo){
|
||||
IPage<BusinessDeptIssue> page = iBusinessDeptIssueService.getBussDeptIssue(pageVo);
|
||||
public ResponseMessage<IPage<BusinessDeptIssue>> getBussDeptIssue(BusinessDeptIssueVo pageVo){
|
||||
IPage<BusinessDeptIssue> page = iBusinessDeptIssueService.getBusinessDeptIssue(pageVo);
|
||||
|
||||
|
||||
return Result.success(page);
|
||||
@@ -57,10 +60,57 @@ public class BusinessDeptIssueController extends BaseController {
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("更新事业部重点问题")
|
||||
public ResponseMessage updateIssueTrack(@RequestBody BusinessDeptIssue issue){
|
||||
boolean b = iBusinessDeptIssueService.updateBussDeptIssue(issue);
|
||||
public ResponseMessage updateBussDeptIssue(@RequestBody BusinessDeptIssue issue){
|
||||
boolean b = iBusinessDeptIssueService.updateBusinessDeptIssue(issue);
|
||||
return Result.success(b);
|
||||
}
|
||||
|
||||
@PostMapping("/closeIssue")
|
||||
@ApiOperation("批量关闭事业部重点问题")
|
||||
public ResponseMessage closeBusinessIssue(@RequestParam(value="ids")String idList){
|
||||
List<String> stringList = Arrays.asList(idList.split(","));
|
||||
boolean b = iBusinessDeptIssueService.closeBusinessDeptIssue(stringList);
|
||||
return Result.success(b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/exportIssue")
|
||||
@ApiOperation("导出事业部重点问题")
|
||||
public void exportIssue(HttpServletResponse response,BusinessDeptIssueVo issue) throws IOException {
|
||||
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
||||
|
||||
//TODO
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||
|
||||
if(issue.getFileName()==null || issue.getFileName()==""){
|
||||
issue.setFileName("事业部重点问题信息");
|
||||
}
|
||||
String fileName = URLEncoder.encode(issue.getFileName(), "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
// List<SarStandUnqualified> data=sarStandUnqualifiedService.getStandUnqualifiedExcelData(standUnqualifiedExcelVO);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(issue.getExportContent());
|
||||
|
||||
BusinessDeptIssueVo businessDeptIssueVo = JSONObject.toJavaObject(jsonObject, BusinessDeptIssueVo.class);
|
||||
IPage<BusinessDeptIssue> page = iBusinessDeptIssueService.getBusinessDeptIssue(businessDeptIssueVo);
|
||||
|
||||
|
||||
// 这里需要设置不关闭流
|
||||
EasyExcel.write(response.getOutputStream(), BusinessDeptIssue.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
|
||||
.doWrite(page.getRecords());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 重置response
|
||||
response.reset();
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.getWriter().println(JSONObject.toJSONString(Result.error()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+25
@@ -3,6 +3,8 @@ package com.adc.da.slrs.sarStandUnqualified.entity;
|
||||
|
||||
import com.adc.da.base.page.BasePage;
|
||||
import com.adc.da.http.PageInfo;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
@@ -16,55 +18,78 @@ import java.util.Date;
|
||||
@TableName("business_dept_issue")
|
||||
public class BusinessDeptIssue {
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField("law_id")
|
||||
private String lawId;
|
||||
|
||||
@ExcelProperty("标准号")
|
||||
@TableField(exist = false)
|
||||
private String lawNumber;
|
||||
|
||||
@ExcelProperty("标准名称")
|
||||
@TableField(exist = false)
|
||||
private String lawName;
|
||||
|
||||
@ExcelProperty("产品类别")
|
||||
@TableField("product_type")
|
||||
private String productType;
|
||||
|
||||
@ExcelProperty("实施实践")
|
||||
@TableField("impl_time")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-mm-dd")
|
||||
private Date implTime;
|
||||
|
||||
@ExcelProperty("实施要求")
|
||||
@TableField("impl_require")
|
||||
private String implRequire;
|
||||
|
||||
@ExcelProperty("资源符合状态")
|
||||
@TableField("conform_situation")
|
||||
private String conformSituation;
|
||||
|
||||
@ExcelProperty("开发情况")
|
||||
@TableField("dev_scheme")
|
||||
private String devScheme;
|
||||
|
||||
@ExcelProperty("sop时间")
|
||||
@TableField("sop_time")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-mm-dd")
|
||||
private Date sopTime;
|
||||
|
||||
@ExcelProperty("完成情况")
|
||||
@TableField("complete_situation")
|
||||
private String completeSituation;
|
||||
|
||||
@ExcelProperty("超出sop时限后计划")
|
||||
@TableField("timeout_situation")
|
||||
private String timeoutSituation;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableLogic(value = "0",delval = "1")
|
||||
private String delFlag;
|
||||
|
||||
@ExcelProperty("责任部门")
|
||||
@TableField("response_dept")
|
||||
private String responseDept;
|
||||
|
||||
@ExcelProperty("责任人")
|
||||
@TableField("response_people")
|
||||
private String responsePeople;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField("is_close")
|
||||
private String isClose;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField(exist = false)
|
||||
private Integer page;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField(exist = false)
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
||||
+17
@@ -2,8 +2,25 @@ package com.adc.da.slrs.sarStandUnqualified.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BusinessDeptIssueVo extends BusinessDeptIssue {
|
||||
|
||||
private String numberOrName;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String idList;
|
||||
|
||||
private String exportContent;
|
||||
|
||||
public List<String> getIdList(){
|
||||
if (this.idList!=null){
|
||||
return Arrays.asList(this.idList.split(","));
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -12,11 +12,13 @@ import java.util.List;
|
||||
public interface IBusinessDeptIssueService extends IService<BusinessDeptIssue> {
|
||||
|
||||
|
||||
public boolean addBussDeptIssue(BusinessDeptIssue obj);
|
||||
public boolean addBusinessDeptIssue(BusinessDeptIssue obj);
|
||||
|
||||
public boolean removeBussDeptIssue(List<String> idList);
|
||||
public boolean removeBusinessDeptIssue(List<String> idList);
|
||||
|
||||
public IPage<BusinessDeptIssue> getBussDeptIssue(BusinessDeptIssueVo objVo);
|
||||
public IPage<BusinessDeptIssue> getBusinessDeptIssue(BusinessDeptIssueVo objVo);
|
||||
|
||||
public boolean updateBussDeptIssue(BusinessDeptIssue obj);
|
||||
public boolean updateBusinessDeptIssue(BusinessDeptIssue obj);
|
||||
|
||||
public boolean closeBusinessDeptIssue(List<String> idList);
|
||||
}
|
||||
|
||||
+53
-24
@@ -1,7 +1,5 @@
|
||||
package com.adc.da.slrs.sarStandUnqualified.service.impl;
|
||||
|
||||
import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao;
|
||||
import com.adc.da.slrs.sarIssueTrack.entity.IssueTrack;
|
||||
import com.adc.da.slrs.sarStandUnqualified.dao.BusinessDeptIssueDao;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssue;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssueVo;
|
||||
@@ -14,8 +12,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class BusinessDeptIssueService extends ServiceImpl<BusinessDeptIssueDao, BusinessDeptIssue> implements IBusinessDeptIssueService {
|
||||
@@ -24,48 +22,79 @@ public class BusinessDeptIssueService extends ServiceImpl<BusinessDeptIssueDao,
|
||||
private BusinessDeptIssueDao businessDeptIssueDao;
|
||||
|
||||
@Override
|
||||
public boolean addBussDeptIssue(BusinessDeptIssue obj) {
|
||||
public boolean addBusinessDeptIssue(BusinessDeptIssue obj) {
|
||||
obj.setId(UUIDUtils.randomUUID20());
|
||||
obj.setDelFlag("0");
|
||||
return this.save(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBussDeptIssue(List<String> idList) {
|
||||
public boolean removeBusinessDeptIssue(List<String> idList) {
|
||||
return removeByIds(idList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<BusinessDeptIssue> getBussDeptIssue(BusinessDeptIssueVo pageVo) {
|
||||
public IPage<BusinessDeptIssue> getBusinessDeptIssue(BusinessDeptIssueVo pageVo) {
|
||||
|
||||
IPage<BusinessDeptIssue> page=new Page<>(pageVo.getPage(),pageVo.getPageSize());
|
||||
IPage<BusinessDeptIssue> page = new Page<>();
|
||||
QueryWrapper<BusinessDeptIssue> wrapper = new QueryWrapper<>();
|
||||
//是否分页
|
||||
if (pageVo.getPage()!=null && pageVo.getPageSize()!=null){
|
||||
page=new Page<>(pageVo.getPage(),pageVo.getPageSize());
|
||||
|
||||
QueryWrapper<BusinessDeptIssue> wrapper = new QueryWrapper<>();
|
||||
|
||||
if (pageVo.getNumberOrName()!=null){
|
||||
wrapper.like("law_number",pageVo.getNumberOrName())
|
||||
.or()
|
||||
.like("law_name",pageVo.getNumberOrName());
|
||||
}
|
||||
}else {
|
||||
Integer count = businessDeptIssueDao.selectCount(wrapper);
|
||||
page=new Page<>(0,count,false);
|
||||
}
|
||||
|
||||
|
||||
if (pageVo.getLawNumber()!=null || pageVo.getProductType()!=null){
|
||||
wrapper.like("law_number",pageVo.getLawNumber())
|
||||
.or()
|
||||
.like("law_name",pageVo.getLawName());
|
||||
}
|
||||
//查询条件
|
||||
if (pageVo.getIsClose()!=null){
|
||||
wrapper.like("is_close",pageVo.getIsClose());
|
||||
}
|
||||
|
||||
if (pageVo.getResponseDept()!=null){
|
||||
wrapper.like("product_type",pageVo.getResponseDept());
|
||||
}
|
||||
if (pageVo.getLawNumber()!=null || pageVo.getLawName()!=null){
|
||||
wrapper.like("laws.LAWS_NUMBER",pageVo.getLawNumber())
|
||||
.or()
|
||||
.like("laws.LAWS_NAME",pageVo.getLawName());
|
||||
}
|
||||
|
||||
page = businessDeptIssueDao.findPage(page, wrapper);
|
||||
if (pageVo.getProductType()!=null){
|
||||
wrapper.like("product_type",pageVo.getProductType());
|
||||
}
|
||||
|
||||
if (pageVo.getResponseDept()!=null){
|
||||
wrapper.like("response_dept",pageVo.getResponseDept());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
if (pageVo.getIdList()!=null){
|
||||
wrapper.in("issue.ID",pageVo.getIdList());
|
||||
}
|
||||
|
||||
page = businessDeptIssueDao.findPage(page, wrapper);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateBussDeptIssue(BusinessDeptIssue obj) {
|
||||
public boolean updateBusinessDeptIssue(BusinessDeptIssue obj) {
|
||||
return this.updateById(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeBusinessDeptIssue(List<String> idList){
|
||||
List<BusinessDeptIssue> collect = idList.stream()
|
||||
.map(item -> {
|
||||
BusinessDeptIssue businessDeptIssue = new BusinessDeptIssue();
|
||||
businessDeptIssue.setId(item);
|
||||
businessDeptIssue.setIsClose("1");
|
||||
return businessDeptIssue;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return this.updateBatchById(collect);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-10
@@ -7,16 +7,16 @@
|
||||
<result property="lawId" column="law_id"/>
|
||||
<result property="lawNumber" column="LAWS_NUMBER"/>
|
||||
<result property="lawName" column="LAWS_NAME"/>
|
||||
<result property="productType" column="productType"/>
|
||||
<result property="implTime" column="implTime"/>
|
||||
<result property="implRequire" column="implRequire"/>
|
||||
<result property="conformSituation" column="conformSituation"/>
|
||||
<result property="devScheme" column="devScheme"/>
|
||||
<result property="sopTime" column="sopTime"/>
|
||||
<result property="completeSituation" column="completeSituation"/>
|
||||
<result property="timeoutSituation" column="timeoutSituation"/>
|
||||
<result property="responseDept" column="responseDept"/>
|
||||
<result property="responsePeople" column="responsePeople"/>
|
||||
<result property="productType" column="product_type"/>
|
||||
<result property="implTime" column="impl_time"/>
|
||||
<result property="implRequire" column="impl_require"/>
|
||||
<result property="conformSituation" column="conform_situation"/>
|
||||
<result property="devScheme" column="dev_scheme"/>
|
||||
<result property="sopTime" column="sop_Time"/>
|
||||
<result property="completeSituation" column="complete_situation"/>
|
||||
<result property="timeoutSituation" column="timeout_situation"/>
|
||||
<result property="responseDept" column="response_dept"/>
|
||||
<result property="responsePeople" column="response_people"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user