导入更换模板加判断

main
杜函宇 7 months ago
parent b4c8a74958
commit 3b7b9066e1

@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -30,6 +31,7 @@ import java.util.List;
@RestController
@Api(tags = "词云")
@RequestMapping("/tcZz/netWorkYq/cy")
@Transactional(rollbackFor = Exception.class)
public class TcCyController extends BaseController {
@Autowired
private ITcCyService tcCyService;

@ -9,6 +9,7 @@ import com.ruoyi.tcZz.service.ITcWljgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -24,6 +25,8 @@ import java.util.List;
@RestController
@Api(tags = "网络监测")
@RequestMapping("/tcZz/networkSecurity/cybersecurity")
@Transactional(rollbackFor = Exception.class)
public class TcWljgController extends BaseController {
@Autowired
private ITcWljgService tcWljgService;

@ -10,6 +10,7 @@ import com.ruoyi.tcZz.service.ITcXtjcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -25,6 +26,7 @@ import java.util.List;
@Api(tags = "系统监测")
@RestController
@RequestMapping("/tcZz/networkSecurity/xtjc")
@Transactional(rollbackFor = Exception.class)
public class TcXtjcController extends BaseController {
@Autowired
private ITcXtjcService tcXtjcService;

@ -9,6 +9,7 @@ import com.ruoyi.tcZz.service.ITcYqxxltjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -24,6 +25,8 @@ import java.util.List;
@RestController
@Api(tags = "舆情信息量统计明細")
@RequestMapping("/tcZz/netWorkYq/yqxxltj")
@Transactional(rollbackFor = Exception.class)
public class TcYqxxltjController extends BaseController {
@Autowired
private ITcYqxxltjService tcYqxxltjService;

@ -9,6 +9,7 @@ import com.ruoyi.tcZz.service.ITcYqzsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -24,6 +25,8 @@ import java.util.List;
@Api(tags = "舆情走势图")
@RestController
@RequestMapping("/tcZz/netWorkYq/yqzs")
@Transactional(rollbackFor = Exception.class)
public class TcYqzsController extends BaseController {
@Autowired
private ITcYqzsService tcYqzsService;

@ -1,12 +1,10 @@
package com.ruoyi.tcZz.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* tc_cy
@ -24,6 +22,12 @@ public class TcCy extends BaseEntity
@ApiModelProperty(value = "id")
private Long id;
/** 区域id */
////,readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城
@Excel(name = "乡镇名称",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
@ApiModelProperty(value = "乡镇名称,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
private String areaId;
/** 词云名称 */
@Excel(name = "词云名称")
@ApiModelProperty(value = "词云名称")
@ -34,9 +38,5 @@ public class TcCy extends BaseEntity
@ApiModelProperty(value = "词云数量")
private Long cyCount;
/** 区域id */
////,readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城
@Excel(name = "区域id")
@ApiModelProperty(value = "区域id,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
private String areaId;
}

@ -29,11 +29,11 @@ public class TcWljg extends BaseEntity {
private Long id;
/**
* id
*
*/
//,readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城"
@ApiModelProperty(value = "区域,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "区域id")
@ApiModelProperty(value = "乡镇名称,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "乡镇名称",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
private String areaId;
/**
@ -41,7 +41,7 @@ public class TcWljg extends BaseEntity {
*/
//,readConverterExp = "1=启用,2=禁用",combo = "启用,禁用"
@ApiModelProperty(value = "启用/禁用,1=启用,2=禁用")
@Excel(name = "启用/禁用")
@Excel(name = "启用/禁用",readConverterExp = "1=启用,2=禁用",combo = "启用,禁用")
private Long isStatus;
/**

@ -26,8 +26,8 @@ public class TcXtjc extends BaseEntity
private Long id;
/** 区域 */
@ApiModelProperty(value = "区域,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "区域",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
@ApiModelProperty(value = "乡镇名称,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "乡镇名称",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
private String areaId;
/** 启用/禁用 */

@ -27,12 +27,12 @@ public class TcYqxxltj extends BaseEntity
private Long id;
/** 区域id */
@Excel(name = "区域id",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
@ApiModelProperty(value = "区域id,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "乡镇名称",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
@ApiModelProperty(value = "乡镇名称,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
private String areaId;
/** 启用/禁用 */
@Excel(name = "1.启用 2.禁用",readConverterExp = "1=启用,2=禁用",combo = "启用,禁用")
@Excel(name = "启用/禁用",readConverterExp = "1=启用,2=禁用",combo = "启用,禁用")
@ApiModelProperty(value = "1.启用 2.禁用,1=启用,2=禁用")
private Long isStatus;

@ -33,8 +33,8 @@ public class TcYqzs extends BaseEntity
/** 区域id */
//,readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城"
@Excel(name = "区域id")
@ApiModelProperty(value = "区域id,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
@Excel(name = "乡镇名称",readConverterExp = "1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城",combo = "太仓市,城厢镇,沙溪镇,浏河镇,浮桥镇,璜泾镇,双凤镇,娄东街道,陆渡街道,科教新城")
@ApiModelProperty(value = "乡镇名称,1=太仓市,2=城厢镇,3=沙溪镇,4=浏河镇,5=浮桥镇,6=璜泾镇,7=双凤镇,8=娄东街道,9=陆渡街道,10=科教新城")
private Long areaId;
/** 日期 */

@ -12,18 +12,11 @@ import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.exception.ServiceException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
@ -350,6 +343,7 @@ public class ExcelUtil<T>
}
// 获取最后一个非空行的行下标比如总行数为n则返回的为n-1
int rows = sheet.getLastRowNum();
List<String> headName1 = new ArrayList<>();
if (rows > 0)
{
// 定义一个map用于存放excel列的序号和field.
@ -362,6 +356,7 @@ public class ExcelUtil<T>
if (StringUtils.isNotNull(cell))
{
String value = this.getCellValue(heard, i).toString();
headName1.add(this.getCellValue(heard, i).toString());
cellMap.put(value, i);
}
else
@ -371,16 +366,21 @@ public class ExcelUtil<T>
}
// 有数据时才处理 得到类的所有field.
List<Object[]> fields = this.getFields();
List<String> headName2 = new ArrayList<>();
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
for (Object[] objects : fields)
{
Excel attr = (Excel) objects[1];
Integer column = cellMap.get(attr.name());
headName2.add(attr.name());
if (column != null)
{
fieldsMap.put(column, objects);
}
}
if (!new HashSet<>(headName2).containsAll(headName1)) {
throw new ServiceException("请选择正确的模板");
}
for (int i = titleNum + 1; i <= rows; i++)
{
// 从第2行开始取数据,默认第一行是表头.

Loading…
Cancel
Save