添加市场法规库清单功能

This commit is contained in:
梁琦涛
2024-07-03 20:47:39 +08:00
parent 52f7345832
commit b12a61b457
7 changed files with 159 additions and 47 deletions
@@ -19,6 +19,7 @@ import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -81,8 +82,8 @@ public class MarketStandardController {
@ApiOperationSupport(order = 3)
@RequiresPermissions("marketStandard:export")
@GetMapping(value = "/exportXls", produces = "application/zip")
public void exportXls(HttpServletResponse response, LawsMarketStandard LawsMarketStandard, HttpServletRequest req) {
marketStandardService.export(response, LawsMarketStandard, "市场法规清单", "市场法规清单", req);
public ModelAndView exportXls(HttpServletResponse response, LawsMarketStandard LawsMarketStandard, HttpServletRequest req) {
return marketStandardService.export(response, LawsMarketStandard, "市场法规清单", "市场法规清单", req);
}
/**
@@ -147,12 +148,9 @@ public class MarketStandardController {
@ApiOperationSupport(order = 7)
@PostMapping(value = "/importExcel")
@RequiresPermissions("marketStandard:importExcel")
public Result<T> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
List<String> errorMessages = marketStandardService.importExcel(file);
if (!errorMessages.isEmpty()) {
return Result.error(MessageUtils.getMessage(ResultCommon.IMPORT_ERROR));
}
return Result.OK();
public Result<?> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
List<LawsMarketStandardDetail> errorMessages = marketStandardService.importExcel(file);
return Result.OK(errorMessages);
}
}
}
@@ -128,12 +128,9 @@ public class MarketStandardDetailController {
@ApiOperationSupport(order = 7)
@PostMapping(value = "/importExcel")
@RequiresPermissions("marketStandard:importExcel")
public Result<T> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
List<String> errorMessages = marketStandardService.importExcel(file);
if (!errorMessages.isEmpty()) {
return Result.error(MessageUtils.getMessage(ResultCommon.IMPORT_ERROR));
}
return Result.OK();
public Result<?> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
List<LawsMarketStandardDetail> list = marketStandardService.importExcel(file);
return Result.OK(list);
}
}
@@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import org.springframework.format.annotation.DateTimeFormat;
/**
@@ -69,6 +72,7 @@ public class LawsMarketStandard implements Serializable {
/**
* 国家
*/
@Excel(name = "国家/地区", width = 15,dicCode = "market_state", needMerge = true)
@Dict(dicCode = "market_state")
@ApiModelProperty(value = "国家")
private String country;
@@ -84,12 +88,14 @@ public class LawsMarketStandard implements Serializable {
* 清单编号
*/
@ApiModelProperty(value = "清单编号")
@Excel(name = "清单编号", width = 15,needMerge = true)
private String manifestNo;
/**
* 清单名称
*/
@ApiModelProperty(value = "清单名称")
@Excel(name = "清单名称", width = 15,needMerge = true)
private String manifestName;
/**
@@ -97,6 +103,7 @@ public class LawsMarketStandard implements Serializable {
*/
@Dict(dicCode = "drive_position")
@ApiModelProperty(value = "驾驶位置")
@Excel(name = "驾驶位置", width = 15,needMerge = true)
private String drivePosition;
/**
@@ -110,6 +117,7 @@ public class LawsMarketStandard implements Serializable {
* 清单版本
*/
@ApiModelProperty(value = "清单版本")
@Excel(name = "清单版本", width = 15,needMerge = true)
private String manifestVersion;
/**
@@ -118,6 +126,7 @@ public class LawsMarketStandard implements Serializable {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "发布时间")
@Excel(name = "发布时间", width = 15,needMerge = true)
private Date releaseDate;
/**
@@ -125,6 +134,7 @@ public class LawsMarketStandard implements Serializable {
*/
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id")
@ApiModelProperty(value = "作者")
@Excel(name = "发布时间", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "id" ,needMerge = true)
private String author;
/**
@@ -146,6 +156,7 @@ public class LawsMarketStandard implements Serializable {
*/
@Dict(dicCode = "manifest_status")
@ApiModelProperty(value = "清单状态")
@Excel(name = "清单状态", width = 15,dicCode = "manifest_status", needMerge = true)
private String manifestStatus;
/**
@@ -174,4 +185,12 @@ public class LawsMarketStandard implements Serializable {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
* 市场法规清单
*/
@ExcelCollection(name="市场法规清单")
@TableField(exist = false)
@ApiModelProperty(value = "市场法规清单")
private List<LawsMarketStandardDetail> list;
}
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
@@ -76,28 +77,66 @@ public class LawsMarketStandardDetail implements Serializable {
* 标准编号
*/
@ApiModelProperty(value = "标准编号")
@Excel(name = "标准编号", width = 15)
private String standardNumber;
/**
* 标准名称
*/
@ApiModelProperty(value = "标准名称")
@Excel(name = "标准名称", width = 15)
private String standardName;
/**
* 标准英文名称
*/
@ApiModelProperty(value = "标准英文名称")
@Excel(name = "标准英文名称", width = 15)
private String standardEnglishName;
/**
* 新生产车实施日期
*/
@Excel(name = "新生产车实施日期", width = 15)
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "新生产车实施日期")
private Date newProductImplDate;
/**
* 新认证车实施日期
*/
@Excel(name = "新认证车实施日期", width = 15)
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "新认证车实施日期")
private Date newAuthImplDate;
/**
* 注册日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@Excel(name = "注册日期", width = 15)
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "注册日期")
private String registrationDate;
/**
* 国家
*/
@Excel(name = "国家/地区", width = 15,dicCode = "market_state")
@TableField(exist = false)
@ApiModelProperty(value = "国家")
private String country;
/**
* 适用车型
*/
@Excel(name = "适用车型", width = 15)
@Dict(dicCode = "applicable_vehicle_type")
@ApiModelProperty(value = "适用车型")
private String applicableVehicle;
/**
* 备注
*/
@@ -108,33 +147,30 @@ public class LawsMarketStandardDetail implements Serializable {
* 认证对象
*/
@ApiModelProperty(value = "认证对象")
@Excel(name = "认证对象", width = 15)
private String authenticationObject;
/**
* 认证交付物
*/
@ApiModelProperty(value = "认证交付物")
@Excel(name = "认证交付物", width = 15)
private String certifyTheDeliverables;
/**
* 类型
*/
@Dict(dicCode = "type")
@Excel(name = "类型", width = 15, dicCode = "type")
@ApiModelProperty(value = "类型")
private String type;
/**
* 适用车型
*/
@Dict(dicCode = "applicable_vehicle_type")
@ApiModelProperty(value = "适用车型")
private String applicableVehicle;
/**
* 动力类型
*/
@Dict(dicCode = "dynamic_type")
@ApiModelProperty(value = "动力类型")
@Excel(name = "动力类型", width = 15, dicCode = "dynamic_type")
private String dynamicType;
/**
@@ -142,12 +178,14 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@ApiModelProperty(value = "主控部门")
@Excel(name = "主控部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
private String mainDept;
/**
* 主控部门专业模块
*/
@ApiModelProperty(value = "主控部门专业模块")
@Excel(name = "主控部门专业模块", width = 15)
private String mainDeptProfMode;
/**
@@ -155,18 +193,21 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@ApiModelProperty(value = "关联部门")
@Excel(name = "关联部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
private String associateDept;
/**
* 关联部门专业模块
*/
@ApiModelProperty(value = "关联部门专业模块")
@Excel(name = "关联部门专业模块", width = 15)
private String associateDeptProfMode;
/**
* 批量限制
*/
@ApiModelProperty(value = "批量限制")
@Excel(name = "批量限制", width = 15)
private String batchLimit;
/**
@@ -174,6 +215,7 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dicCode = "automatic_driving_level")
@ApiModelProperty(value = "自动驾驶等级")
@Excel(name = "自动驾驶等级", width = 15,dicCode = "automatic_driving_level")
private String autopilotLevel;
/**
@@ -181,23 +223,9 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dicCode = "requirement_type")
@ApiModelProperty(value = "要求类型")
@Excel(name = "要求类型", width = 15,dicCode = "requirement_type")
private String requireType;
/**
* 新生产车实施日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "新生产车实施日期")
private Date newProductImplDate;
/**
* 新认证车实施日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "新认证车实施日期")
private Date newAuthImplDate;
/**
* 清单Id
@@ -8,6 +8,8 @@ import com.jero.modules.laws.marketStandard.entity.LawsMarketStandard;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ThinkBook
* @description 针对表【laws_market_standard(市场法规)】的数据库操作Mapper
@@ -17,6 +19,8 @@ import org.apache.ibatis.annotations.Param;
public interface LawsMarketStandardMapper extends BaseMapper<LawsMarketStandard> {
IPage<LawsMarketStandard> queryByPage(Page<LawsMarketStandard> page, @Param(Constants.WRAPPER) QueryWrapper<LawsMarketStandard> queryWrapper);
List<LawsMarketStandard> queryByPage(@Param(Constants.WRAPPER) QueryWrapper<LawsMarketStandard> queryWrapper);
}
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.laws.marketStandard.entity.LawsMarketStandardDetail;
import com.jero.modules.laws.marketStandard.entity.MarketStandardDetailVO;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -32,7 +33,7 @@ public interface ILawsMarketStandardService extends IService<LawsMarketStandard>
* @param sheetName
* @param req
*/
void export(HttpServletResponse response, LawsMarketStandard lawsMarketStandard, String fileName, String sheetName, HttpServletRequest req);
ModelAndView export(HttpServletResponse response, LawsMarketStandard lawsMarketStandard, String fileName, String sheetName, HttpServletRequest req);
/**
* 查看
@@ -67,5 +68,5 @@ public interface ILawsMarketStandardService extends IService<LawsMarketStandard>
* @param file
* @return
*/
List<String> importExcel(MultipartFile file);
List<LawsMarketStandardDetail> importExcel(MultipartFile file);
}
@@ -5,9 +5,12 @@ 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 com.jero.common.api.vo.Result;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.query.QueryGenerator;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.laws.marketStandard.constans.MarketStandardConstants;
import com.jero.modules.laws.marketStandard.entity.LawsMarketStandard;
import com.jero.modules.laws.marketStandard.entity.LawsMarketStandardDetail;
@@ -15,20 +18,29 @@ import com.jero.modules.laws.marketStandard.entity.MarketStandardDetailVO;
import com.jero.modules.laws.marketStandard.mapper.LawsMarketStandardMapper;
import com.jero.modules.laws.marketStandard.service.ILawsMarketStandardDetailService;
import com.jero.modules.laws.marketStandard.service.ILawsMarketStandardService;
import com.jero.modules.sys.entity.LawsWorkingGroupUserImport;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -47,6 +59,10 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
@Resource
private ISysBaseAPI sysBaseAPI;
public static final String CLASS = "entity";
public static final String PARAMS = "params";
public static final String FILE_NAME = "fileName";
/**
* 法规管理员
*/
@@ -115,14 +131,63 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
}
@Override
public List<String> importExcel(MultipartFile file) {
return null;
public List<LawsMarketStandardDetail> importExcel(MultipartFile file) {
List<LawsMarketStandardDetail> list = new ArrayList<>();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
return ExcelImportUtil.importExcel(file.getInputStream(), LawsMarketStandardDetail.class, params);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
return list;
}
@Override
public void export(HttpServletResponse response, LawsMarketStandard lawsMarketStandard, String fileName, String sheetName, HttpServletRequest req) {
//TODO 导出具体模板查看NAS文档
public ModelAndView export(HttpServletResponse response, LawsMarketStandard marketStandard, String fileName, String sheetName, HttpServletRequest req) {
QueryWrapper<LawsMarketStandard> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(marketStandard.getManifestNo()),
"ms.manifest_no", marketStandard.getManifestNo());
queryWrapper.like(StringUtils.isNotBlank(marketStandard.getManifestName()),
"ms.manifest_name", marketStandard.getManifestName());
if (StringUtils.isNotBlank(marketStandard.getCountry())) {
queryWrapper.in("ms.country", Arrays.asList(marketStandard.getCountry().split(",")));
}
queryWrapper.eq(StringUtils.isNotBlank(marketStandard.getDrivePosition()),
"ms.drive_position", marketStandard.getDrivePosition());
queryWrapper.like(StringUtils.isNotBlank(marketStandard.getAuthor()),
"CONCAT(u.realname, '(', u.username, ')')", marketStandard.getAuthor());
queryWrapper.orderByDesc("ms.create_time");
List<LawsMarketStandard> listLawsMarketStandard = marketStandardMapper.queryByPage(queryWrapper);
if(!CollectionUtils.isEmpty(listLawsMarketStandard)){
for (LawsMarketStandard lawsMarketStandard : listLawsMarketStandard) {
// 列表数据
LambdaQueryWrapper<LawsMarketStandardDetail> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LawsMarketStandardDetail::getManifestId, lawsMarketStandard.getId());
List<LawsMarketStandardDetail> pageData = lawsMarketStandardDetailService.list(wrapper);
lawsMarketStandard.setList(pageData);
}
}
// AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
String title = "市场法规清单";
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject("", title);
mv.addObject(CLASS, LawsMarketStandard.class);
ExportParams exportParams = new ExportParams(null, title);
// 导出xls
mv.addObject(PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, listLawsMarketStandard);
return mv;
}
@Override