Commit 725709bd by wqc

青秀模型导出

parent 4c4686b4
package com.zq.model.controller; package com.zq.model.controller;
import com.zq.common.annotation.AnonymousAccess;
import com.zq.common.utils.AssertUtils; import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo; import com.zq.common.vo.ResultVo;
import com.zq.model.service.FfzdService; import com.zq.model.service.FfzdService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RestController @RestController
@RequestMapping("/model/ffzd") @RequestMapping("/model/ffzd")
...@@ -19,6 +22,8 @@ public class FfzdController { ...@@ -19,6 +22,8 @@ public class FfzdController {
private FfzdService ffzdService; private FfzdService ffzdService;
@PostMapping("/uploadFile") @PostMapping("/uploadFile")
@ApiOperation("上传解析公示表")
@AnonymousAccess
public ResultVo uploadFile(@RequestParam("file") MultipartFile[] multipartFiles) { public ResultVo uploadFile(@RequestParam("file") MultipartFile[] multipartFiles) {
AssertUtils.notNull(multipartFiles, "文件不能为空!"); AssertUtils.notNull(multipartFiles, "文件不能为空!");
try { try {
...@@ -28,4 +33,31 @@ public class FfzdController { ...@@ -28,4 +33,31 @@ public class FfzdController {
return ResultVo.fail(500, "文件解析失败"); return ResultVo.fail(500, "文件解析失败");
} }
} }
@PostMapping("/analyFile")
@ApiOperation("上传解析非诉行政强制执行案件")
@AnonymousAccess
public ResultVo analyFile(@RequestParam("file") MultipartFile[] multipartFiles) {
AssertUtils.notNull(multipartFiles, "文件不能为空!");
try {
return ResultVo.success(ffzdService.analyFile(multipartFiles));
} catch (Exception e) {
e.printStackTrace();
return ResultVo.fail(500, "文件解析失败");
}
}
@PostMapping("/queryData")
@ApiOperation("数据碰撞")
public ResultVo queryData(){
return ResultVo.success(ffzdService.queryData());
}
@PostMapping("/downloadData")
@ApiOperation("导出数据表")
public ResultVo downloadData(HttpServletResponse response){
return ResultVo.success(ffzdService.downloadData(response));
}
} }
...@@ -24,6 +24,9 @@ public class CityManageEnforceLaw { ...@@ -24,6 +24,9 @@ public class CityManageEnforceLaw {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer id;
@ApiModelProperty("xuhao")
private String xuhao;
@ApiModelProperty("ajlb") @ApiModelProperty("ajlb")
private String cfjg; private String cfjg;
......
package com.zq.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "non_litigation_force_case")
public class NonLitigationForceCase {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("xuhao")
private String xuhao;
@ApiModelProperty("caseNo")
private String caseNo;
@ApiModelProperty("caseName")
private String caseName;
@ApiModelProperty("standDate")
private String standDate;
@ApiModelProperty("ruleResult")
private String ruleResult;
private Date createTime;
}
package com.zq.model.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.model.entity.CityManageEnforceLaw;
import com.zq.model.entity.NonLitigationForceCase;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface FsxzqzzxCaseDao extends BaseMapper<NonLitigationForceCase> {
}
...@@ -5,15 +5,23 @@ import cn.hutool.core.convert.Convert; ...@@ -5,15 +5,23 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zq.common.exception.BusinessException; import com.zq.common.exception.BusinessException;
import com.zq.model.entity.CityManageEnforceLaw; import com.zq.model.entity.CityManageEnforceLaw;
import com.zq.model.entity.NonLitigationForceCase;
import com.zq.model.mapper.CgzfInfoDao; import com.zq.model.mapper.CgzfInfoDao;
import com.zq.model.mapper.FsxzqzzxCaseDao;
import com.zq.system.utils.FileUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class FfzdService { public class FfzdService {
...@@ -21,6 +29,9 @@ public class FfzdService { ...@@ -21,6 +29,9 @@ public class FfzdService {
@Resource @Resource
private CgzfInfoDao cgzfInfoDao; private CgzfInfoDao cgzfInfoDao;
@Resource
private FsxzqzzxCaseDao fsxzqzzxCaseDao;
public Object uploadFile(MultipartFile[] multipartFiles) { public Object uploadFile(MultipartFile[] multipartFiles) {
for (MultipartFile file : multipartFiles) { for (MultipartFile file : multipartFiles) {
ExcelReader reader; ExcelReader reader;
...@@ -31,10 +42,11 @@ public class FfzdService { ...@@ -31,10 +42,11 @@ public class FfzdService {
throw new BusinessException("文件解析失败"); throw new BusinessException("文件解析失败");
} }
CityManageEnforceLaw enforceLaw = new CityManageEnforceLaw(); CityManageEnforceLaw enforceLaw = new CityManageEnforceLaw();
List<List<Object>> readList = reader.read(1); List<List<Object>> readList = reader.read(2);
for (List<Object> objectList : readList) { for (List<Object> objectList : readList) {
int index = 0; int index = 0;
enforceLaw.setCfjg(Convert.toStr(CollUtil.get(objectList, index))); enforceLaw.setXuhao(Convert.toStr(CollUtil.get(objectList, index)));
enforceLaw.setCfjg(Convert.toStr(CollUtil.get(objectList, index++)));
enforceLaw.setAjlb(Convert.toStr(CollUtil.get(objectList, index++))); enforceLaw.setAjlb(Convert.toStr(CollUtil.get(objectList, index++)));
enforceLaw.setCfzl(Convert.toStr(CollUtil.get(objectList, index++))); enforceLaw.setCfzl(Convert.toStr(CollUtil.get(objectList, index++)));
enforceLaw.setXzxdrmc(Convert.toStr(CollUtil.get(objectList, index++))); enforceLaw.setXzxdrmc(Convert.toStr(CollUtil.get(objectList, index++)));
...@@ -50,16 +62,74 @@ public class FfzdService { ...@@ -50,16 +62,74 @@ public class FfzdService {
enforceLaw.setCreateTime(DateUtil.date()); enforceLaw.setCreateTime(DateUtil.date());
cgzfInfoDao.insert(enforceLaw); cgzfInfoDao.insert(enforceLaw);
} }
} }
return null; List<CityManageEnforceLaw> enforceLaws = cgzfInfoDao.selectList(new LambdaQueryWrapper<CityManageEnforceLaw>());
return enforceLaws;
} }
public Object analyFile(MultipartFile[] multipartFiles) {
for (MultipartFile file : multipartFiles) {
ExcelReader reader;
try {
reader = ExcelUtil.getReader(file.getInputStream());
} catch (IOException e) {
e.printStackTrace();
throw new BusinessException("文件解析失败");
}
NonLitigationForceCase aCase = new NonLitigationForceCase();
List<List<Object>> readList = reader.read(2);
for (List<Object> objectList : readList) {
int index = 1;
aCase.setXuhao(Convert.toStr(CollUtil.get(objectList, index)));
aCase.setCaseNo(Convert.toStr(CollUtil.get(objectList, index++)));
aCase.setCaseName(Convert.toStr(CollUtil.get(objectList, index++)));
aCase.setStandDate(Convert.toStr(CollUtil.get(objectList, index++)));
aCase.setRuleResult(Convert.toStr(CollUtil.get(objectList, index++)));
aCase.setCreateTime(DateUtil.date());
fsxzqzzxCaseDao.insert(aCase);
}
}
List<NonLitigationForceCase> caseList = fsxzqzzxCaseDao.selectList(new LambdaQueryWrapper<NonLitigationForceCase>());
return caseList;
}
public List<NonLitigationForceCase> queryData() {
List<NonLitigationForceCase> caseList = fsxzqzzxCaseDao.selectList(new LambdaQueryWrapper<NonLitigationForceCase>());
String caseName = null;
for (NonLitigationForceCase forceCase : caseList) {
caseName = forceCase.getCaseName();
List<CityManageEnforceLaw> lawList = cgzfInfoDao.selectList(new LambdaQueryWrapper<CityManageEnforceLaw>());
String xzxdrlb = null;
for (CityManageEnforceLaw law : lawList) {
xzxdrlb = law.getXzxdrlb();
if (caseName.contains(xzxdrlb)) {
LambdaQueryWrapper<NonLitigationForceCase> wrapper = new LambdaQueryWrapper<>();
wrapper.like(NonLitigationForceCase::getCaseName, xzxdrlb);
List<NonLitigationForceCase> forceCases = fsxzqzzxCaseDao.selectList(wrapper);
return forceCases;
}
}
}
return null;
}
public Object downloadData(HttpServletResponse response) {
List<NonLitigationForceCase> caseList = queryData();
List<Map<String, Object>> list = new ArrayList<>();
for (NonLitigationForceCase cases : caseList) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("案号", cases.getCaseNo());
map.put("案件名称", cases.getCaseName());
map.put("立案日期", cases.getStandDate());
map.put("裁定结果", cases.getRuleResult());
list.add(map);
}
try {
FileUtil.downloadNameExcel(list, response,"怠于申请强制执行线索数据");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
} }
...@@ -176,6 +176,27 @@ public class FileUtil extends cn.hutool.core.io.FileUtil { ...@@ -176,6 +176,27 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
IoUtil.close(out); IoUtil.close(out);
} }
/**
* 导出excel
*/
public static void downloadNameExcel(List<Map<String, Object>> list, HttpServletResponse response, String fileName) throws IOException {
String tempPath = fileName + ".xlsx";
File file = new File(tempPath);
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(list, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
ServletOutputStream out = response.getOutputStream();
// 终止后删除临时文件
file.deleteOnExit();
writer.flush(out, true);
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
public static String getFileType(String type) { public static String getFileType(String type) {
String documents = "txt doc pdf ppt pps xlsx xls docx"; String documents = "txt doc pdf ppt pps xlsx xls docx";
String music = "mp3 wav wma mpa ram ra aac aif m4a"; String music = "mp3 wav wma mpa ram ra aac aif m4a";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment