Commit 50a709a3 authored by hubaoshan's avatar hubaoshan

导入

parent 8987cf96
......@@ -3,8 +3,10 @@ package org.rcisoft.bus.jnP7sj.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjPageHandleDto;
import org.rcisoft.bus.jnP7sj.entity.jnP7sj;
import org.rcisoft.bus.jnP7sj.service.jnP7sjService;
import org.rcisoft.core.anno.CyEncryptSm4Anno;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
......@@ -17,6 +19,7 @@ import org.rcisoft.util.ExportToExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
......@@ -107,4 +110,25 @@ public class jnP7sjController extends CyPaginationController<jnP7sj> {
List<jnP7sj> jnP7sjList = jnP7sjServiceImpl.export(jnP7sj);
ExportToExcelUtil.exportExcel(jnP7sjList, "jnP7sj信息", "jnP7sj信息", jnP7sj.class, excelName, response);
}
@CyOpeLogAnno(title = "system-jnP7sj管理-下载空模板", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value = "下载空模板", notes = "下载空模板")
@GetMapping(value = "/jnP7sjDownEmptyTemplate")
public void jnsp7xtmDqsjDownEmptyTemplate(jnP7sjPageHandleDto jnP7sjPageHandleDto, HttpServletResponse response) {
jnP7sjServiceImpl.jnP7sjDownEmptyTemplate(jnP7sjPageHandleDto,response);
}
/**
* 导入模板
* **/
@CyOpeLogAnno(title = "system-检查申请管理-jnP7sj导入", businessType = CyLogTypeEnum.IMPORT)
@ApiOperation(value = "jnP7sj导入", notes = "jnP7sj导入")
@PostMapping(value = "/jnP7sjImportDtoExcel")
@CyEncryptSm4Anno
public CyResult jnP7sjImportDtoExcel(MultipartFile file) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
jnP7sjServiceImpl.jnP7sjImportDtoExcel(file));
}
}
......@@ -15,4 +15,16 @@ public interface jnP7sjRepository extends CyBaseMapper<jnP7sj> {
List<String> getMonthList();
void batchAddjnP7sj(@Param("list") List<jnP7sj> list);
/**
* 根据cc 查询客户有关的信息
* **/
List<jnP7sj> queryCustomer(@Param("cc") String cc);
/**
* 根据pn 查询sypn的值
* **/
List<String> querySypnByPn(@Param("pn") String pn);
}
package org.rcisoft.bus.jnP7sj.dto;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
@Data
public class jnP7sjExportTemplateDto {
@Excel(name = "term", orderNum = "0", width = 20)
private String term;
@Excel(name = "month", orderNum = "1", width = 20)
private String month;
@Excel(name = "half", orderNum = "2", width = 20)
private String half;
@Excel(name = "quarter", orderNum = "3", width = 20)
private String quarter;
@Excel(name="io", orderNum = "4",width = 20)
private String io;
@Excel(name = "cc", orderNum = "5", width = 20)
private String cc;
@Excel(name = "cn", orderNum = "6", width = 20)
private String cn;
@Excel(name = "route", orderNum = "7", width = 20)
private String route;
@Excel(name = "pc", orderNum = "8", width = 20)
private String pc;
@Excel(name = "factory", orderNum = "9", width = 20)
private String factory;
@Excel(name = "size", orderNum = "10", width = 20)
private String size;
@Excel(name = "pn", orderNum = "11", width = 20)
private String pn;
@Excel(name = "po", orderNum = "12", width = 20)
private String po;
@Excel(name = "fc", orderNum = "13", width = 20)
private String fc;
@Excel(name = "qty", orderNum = "14", width = 20)
private String qty;
@Excel(name = "sypn", orderNum = "15", width = 20)
private String sypn;
}
package org.rcisoft.bus.jnP7sj.dto;
import lombok.Data;
import java.util.List;
@Data
public class jnP7sjImportDto {
private String filename;
/**
* 文件导入之后插入文件的数据
*/
private List<jnP7sjExportTemplateDto> insert;
/**
* 成功之后返回的条数
* **/
private Integer rows;
/**
* 总共多少条数据
* **/
private Integer total;
}
package org.rcisoft.bus.jnP7sj.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class jnP7sjPageHandleDto {
// 总数
private Integer total;
// 当前页
private Integer page;
// 页长度
private Integer rows;
// 类型 1:月度表重置 2.客户表重置
private String type;
// term
private String term;
// month
private String month;
// cc
private String cc;
// cn
private String cn;
// sypn
private String sypn;
}
package org.rcisoft.bus.jnP7sj.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjExportTemplateDto;
import org.rcisoft.core.entity.CyIdIncreEntity;
import java.math.BigDecimal;
......@@ -10,7 +12,7 @@ import java.math.BigDecimal;
@Data
@TableName("jnsp7xtm_dqsj")
public class jnP7sj extends CyIdIncreEntity<jnP7sj> {
@Excel(name = "term", orderNum = "0", width = 20)
@Excel(name = "businessId", orderNum = "0", width = 20)
private Integer businessId;
@Excel(name = "term", orderNum = "1", width = 20)
private String term;
......@@ -45,4 +47,10 @@ public class jnP7sj extends CyIdIncreEntity<jnP7sj> {
@Excel(name="qty", orderNum = "16",width = 20)
private BigDecimal qty;
public static jnP7sj generatejnP7sj(jnP7sjExportTemplateDto jnP7sjExportTemplateDto, jnP7sj jnP7sj) {
BeanUtil.copyProperties(jnP7sjExportTemplateDto, jnP7sj);
return jnP7sj;
}
}
package org.rcisoft.bus.jnP7sj.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.rcisoft.bus.jnP7sj.dao.jnP7sjRepository;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjExportTemplateDto;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjImportDto;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjPageHandleDto;
import org.rcisoft.bus.jnP7sj.entity.jnP7sj;
import org.rcisoft.bus.jnP7sj.service.jnP7sjService;
import org.rcisoft.core.exception.CyServiceException;
import org.rcisoft.core.model.CyPageInfo;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.enums.CyImportErrCodeEnum;
import org.rcisoft.util.ExportToExcelUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class jnP7sjServiceImpl extends ServiceImpl<jnP7sjRepository, jnP7sj> implements jnP7sjService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
private static Lock topFourButtonLock = new ReentrantLock();
//
private static Lock finallyButtonLockLock = new ReentrantLock();
@Value("${jnP7sj.importBatchAddSize}")
private Integer importBatchAddSize;
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public CyPersistModel persist(jnP7sj jnP7sj) {
int line=baseMapper.insert(jnP7sj);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
jnP7sj.getBusinessId()+"的信息");
int line = baseMapper.insert(jnP7sj);
log.debug(CyUserUtil.getAuthenUsername() + "新增了ID为" +
jnP7sj.getBusinessId() + "的信息");
return new CyPersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public CyPersistModel remove(jnP7sj jnP7sj) {
int line = baseMapper.realDelete(jnP7sj);
log.debug(CyUserUtil.getAuthenUsername()+"删除了ID为"+
jnP7sj.getBusinessId()+"的信息");
log.debug(CyUserUtil.getAuthenUsername() + "删除了ID为" +
jnP7sj.getBusinessId() + "的信息");
return new CyPersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public CyPersistModel removeLogical(jnP7sj jnP7sj) {
jnP7sj.setDeleted();
int line = baseMapper.deleteById(jnP7sj);
log.debug(CyUserUtil.getAuthenUsername()+"逻辑删除了ID为"+
jnP7sj.getBusinessId()+"的信息");
log.debug(CyUserUtil.getAuthenUsername() + "逻辑删除了ID为" +
jnP7sj.getBusinessId() + "的信息");
return new CyPersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public CyPersistModel merge(jnP7sj jnP7sj) {
int line = baseMapper.updateById(jnP7sj);
log.debug(CyUserUtil.getAuthenUsername()+"修改了ID为"+ jnP7sj.getBusinessId()+"的信息");
log.debug(CyUserUtil.getAuthenUsername() + "修改了ID为" + jnP7sj.getBusinessId() + "的信息");
return new CyPersistModel(line);
}
@Override
public jnP7sj findById(int id) {
return baseMapper.selectById(id);
}
@Override
public IPage<jnP7sj> findAllByPagination(CyPageInfo<jnP7sj> paginationUtility, jnP7sj jnP7sj) {
return baseMapper.queryjnP7sjPaged(paginationUtility,jnP7sj);
return baseMapper.queryjnP7sjPaged(paginationUtility, jnP7sj);
}
@Override
public List<jnP7sj> findAll(jnP7sj jnP7sj) {
return baseMapper.queryjnP7sj(jnP7sj);
}
@Override
public List<jnP7sj> export(jnP7sj jnP7sj) {
List<jnP7sj> jnP7sjList = baseMapper.queryjnP7sj(jnP7sj);
return jnP7sjList;
}
@Override
public void jnP7sjDownEmptyTemplate(jnP7sjPageHandleDto jnsp7xtmDqsjPageHandleDto, HttpServletResponse response) {
// 导出空模板
OutputStream outputStream = null;
Workbook workbook = null;
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("试题数据信息.xlsx", "UTF-8"));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
List<jnP7sjExportTemplateDto> exportList = new ArrayList<>();
workbook = ExcelExportUtil.exportExcel(exportParams, jnP7sjExportTemplateDto.class, exportList);
Sheet sheet = workbook.getSheetAt(0);
String[] termList = new String[]{"L","c"};
ExportToExcelUtil.XSSFSetDropDownAndHidden(termList, workbook, sheet, 1, 100000, 0, 0);
outputStream = response.getOutputStream();
workbook.write(outputStream);
} catch (IOException e) {
throw new CyServiceException(e.getMessage());
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (IOException var11) {
log.info("context:" + var11);
}
}
}
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public jnP7sjImportDto jnP7sjImportDtoExcel(MultipartFile file) {
jnP7sjImportDto jnP7sjImportDto = new jnP7sjImportDto();
try {
if (finallyButtonLockLock.tryLock(1000, TimeUnit.MILLISECONDS)) {
try {
// 要添加的数据行数据
int rows = 0;
// 要添加的list
List<jnP7sj> jnP7sjList = new ArrayList<>();
List<jnP7sjExportTemplateDto> dataList = ExportToExcelUtil.importExcelNotTitle(file, 1, 1, jnP7sjExportTemplateDto.class);
if (CollectionUtil.isEmpty(dataList)) {
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), "导入模板为空");
}
for (int i = 0; i < dataList.size(); i++) {
/**
* 1.校验 month和cc和pn 必填
* **/
if (StringUtils.isNotBlank(dataList.get(i).getMonth()) && StringUtils.isNotBlank(dataList.get(i).getCc()) && StringUtils.isNotBlank(dataList.get(i).getPn())) {
/**
* 2.校验 amt,rate,up,qty,fc,po 格式是数据
* **/
if ((dataList.get(i).getMonth().length() != 6 && this.isValidDate(dataList.get(i).getMonth())))
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), "第" + (i + 1) + "行month格式不对");
if (!StringUtils.isEmpty(dataList.get(i).getQty())) {
if (!isValidIntegerOrLessThanNDecimal(dataList.get(i).getQty(), 2))
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), "第" + (i + 1) + "行qty格式不对");
}
if (!StringUtils.isEmpty(dataList.get(i).getFc())) {
if (!isValidIntegerOrLessThanNDecimal(dataList.get(i).getFc(), 2))
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), "第" + (i + 1) + "行fc格式不对");
}
if (!StringUtils.isEmpty(dataList.get(i).getPo())) {
if (!isValidIntegerOrLessThanNDecimal(dataList.get(i).getPo(), 2))
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), "第" + (i + 1) + "行po格式不对");
}
/**
* 3.转换jnsp7xtmDqsj
* **/
jnP7sj jnP7sj = new jnP7sj();
if (StringUtils.isNotEmpty(dataList.get(i).getCc())) {
List<jnP7sj> dqsjList = baseMapper.queryCustomer(dataList.get(i).getCc());
if (CollectionUtil.isNotEmpty(dqsjList)) {
jnP7sj = dqsjList.get(0);
}
}
jnP7sj finallyjnP7sj = jnP7sj.generatejnP7sj(dataList.get(i), jnP7sj);
if (StringUtils.isNotEmpty(dataList.get(i).getPn())) {
List<String> list = baseMapper.querySypnByPn(dataList.get(i).getPn());
if (CollectionUtil.isNotEmpty(list)) {
finallyjnP7sj.setSypn(list.get(0));
}
}
jnP7sjList.add(finallyjnP7sj);
rows = rows + 1;
if (jnP7sjList.size() == importBatchAddSize) {
this.importBatchAddList(jnP7sjList);
jnP7sjList.clear();
}
}
}
if (CollectionUtil.isNotEmpty(jnP7sjList)) {
baseMapper.batchAddjnP7sj(jnP7sjList);
}
jnP7sjImportDto.setTotal(dataList.size());
jnP7sjImportDto.setRows(rows);
return jnP7sjImportDto;
} catch (Exception e) {
e.printStackTrace();
throw new CyServiceException(CyImportErrCodeEnum.IMPORT_ERR.getCode(), e.getMessage());
} finally {
finallyButtonLockLock.unlock();
}
} else {
throw new CyServiceException(501, "该功能使用频繁,请稍后重试");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return jnP7sjImportDto;
}
private void importBatchAddList(List<jnP7sj> list) {
baseMapper.batchAddjnP7sj(list);
}
/**
* 校验月份的格式是否正确
**/
public boolean isValidDate(String str) {
String pattern = "^\\d{4}\\d{2}$"; // 前四位是年,后两位是月份
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
return m.matches();
}
public static boolean isValidIntegerOrLessThanNDecimal(String str, int n) {
try {
BigDecimal bd = new BigDecimal(str);
if (bd.scale() <= n) {
return true;
}
} catch (NumberFormatException e) {
}
return false;
}
}
package org.rcisoft.bus.jnP7sj.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjImportDto;
import org.rcisoft.bus.jnP7sj.dto.jnP7sjPageHandleDto;
import org.rcisoft.bus.jnP7sj.entity.jnP7sj;
import org.rcisoft.core.model.CyPageInfo;
import org.rcisoft.core.model.CyPersistModel;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface jnP7sjService {
......@@ -24,5 +28,8 @@ public interface jnP7sjService {
List<jnP7sj> export(jnP7sj jnP7sj);
void jnP7sjDownEmptyTemplate(jnP7sjPageHandleDto jnsp7xtmDqsjPageHandleDto, HttpServletResponse response);
jnP7sjImportDto jnP7sjImportDtoExcel(MultipartFile file);
}
package org.rcisoft.enums;
public enum CyImportErrCodeEnum {
IMPORT_ERR(7000);
private Integer code;
public Integer getCode() {
return code;
}
CyImportErrCodeEnum(Integer code) {
this.code = code;
}
public void setCode(Integer code) {
this.code = code;
}
}
package org.rcisoft.util;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.rcisoft.core.exception.CyServiceException;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -25,6 +32,109 @@ import java.util.Map;
*/
@Slf4j
public class ExportToExcelUtil extends CyEpExcelUtil {
public static <T> List<T> importExcelNotTitle(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (file == null) {
return null;
} else {
ImportParams params = new ImportParams();
List list = null;
try {
list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
return list;
} catch (Exception var7) {
throw new CyServiceException(502, "模板格式错误");
}
}
}
/**
* 为Excel表格添加下拉选项
* 解决单元格在某个时间点只能访问有限数据量而导致无法显示下拉选项的问题
* 适用于下拉选项总字节数大于 255 个字节的情况
* 缺点:会创建一个隐藏的sheet用于存放下拉选项
*
* @param formulaString 下拉选项数据
* @param workbook Excel工作簿
* @param sheet 设置下拉选项的工作表
* @param firstRow 起始行
* @param lastRow 终止行
* @param firstCol 起始列
* @param lastCol 终止列
*/
public static void XSSFSetDropDownAndHidden(String[] formulaString, Workbook workbook, Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
// 计算下拉选项全部字节数
int totalBytes = Arrays.stream(formulaString)
.mapToInt(str -> str.getBytes(StandardCharsets.UTF_8).length)
.sum();
// 创建一个数据验证助手
DataValidationHelper dvHelper = sheet.getDataValidationHelper();
if (totalBytes > 255) {
// 当总选项字节数大于 255 时创建隐藏工作表用于存放下拉选项
// 创建sheet,写入枚举项
//判断当前sheet不存在则创建
Sheet hideSheet = workbook.getSheet("hiddenSheet");
if (workbook.getSheet("hiddenSheet") == null) {
hideSheet = workbook.createSheet("hiddenSheet");
}
for (int i = 0; i < formulaString.length; i++) {
// 将下拉选项值存放在目标工作表下拉项目相同列
hideSheet.createRow(i).createCell(firstCol).setCellValue(formulaString[i]);
}
// 创建名称,可被其他单元格引用
//判断当前名称不存在则创建
Name hiddenSheetName = workbook.getName("hidden");
if (workbook.getName("hidden") == null) {
hiddenSheetName = workbook.createName();
hiddenSheetName.setNameName("hidden");
}
// 设置名称引用的公式
// 使用像'A1:B1'这样的相对值会导致在Microsoft Excel中使用工作簿时名称所指向的单元格的意外移动,
// 通常使用绝对引用,例如'$A$1:$B$1'可以避免这种情况。
// 根据 firstCol 计算引用索引字母
StringBuilder columnLetter = new StringBuilder();
int columnIndex = firstCol;
while (columnIndex >= 0) {
int rem = columnIndex % 26;
columnLetter.append((char) ('A' + rem));
columnIndex = (columnIndex / 26) - 1;
}
columnLetter.reverse();
hiddenSheetName.setRefersToFormula("hiddenSheet!$" + columnLetter + "$1:$" + columnLetter + "$" + formulaString.length);
// 获取上文名称内数据
DataValidationConstraint constraint = dvHelper.createFormulaListConstraint("hidden");
// 设置下拉框位置
CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, firstCol, lastCol);
DataValidation dataValidation = dvHelper.createValidation(constraint, addressList);
// 处理Excel兼容性问题
if (dataValidation instanceof XSSFDataValidation) {
// 数据校验
dataValidation.setSuppressDropDownArrow(true);
dataValidation.setShowErrorBox(true);
} else {
dataValidation.setSuppressDropDownArrow(false);
}
// 作用在目标sheet上
sheet.addValidationData(dataValidation);
// 设置hiddenSheet隐藏
int hideSheetIndex = workbook.getSheetIndex(hideSheet);
workbook.setSheetHidden(hideSheetIndex, true);
} else {
// 当总选项字节数不大于 255 时使用传统方式创建下拉选项
// 创建下拉列表约束
DataValidationConstraint dvConstraint = dvHelper.createExplicitListConstraint(formulaString);
// 设置数据验证的单元格区域(从firstRow行firstCol列到lastRow行lastCol列)
CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, firstCol, lastCol);
// 创建数据验证对象并添加到工作表
DataValidation validation = dvHelper.createValidation(dvConstraint, addressList);
sheet.addValidationData(validation);
}
}
// 导出动态列
/**
* entityList 表头
......
......@@ -121,3 +121,17 @@ syncSchedule:
message:
config: true
jnsp7xtm:
export:
# 每次写入excel的长度
pageSize: 20
jnP7sj:
# 每次查询分页的长度
pageQuestSize: 5000
# 每次添加到数据库的长度
batchAddPagesize: 30
# 导出时添加带数据库的数据长度
importBatchAddSize: 30
# service 要重置的数据库
shema: 'demo.dbo'
......@@ -20,6 +20,13 @@
<result column="qty" jdbcType="DECIMAL" property="qty"/>
</resultMap>
<insert id="batchAddjnP7sj" parameterType="java.util.List">
INSERT into jnsp7xtm_dqsj(term,half,quarter,month,cc,cn,io,route,pc,factory,size,pn,po,fc,qty) values
<foreach collection="list" item="item" separator=",">
(#{item.term}, #{item.half},#{item.quarter},#{item.month},#{item.cc},#{item.cn},#{item.io},#{item.route},#{item.pc},#{item.factory},#{item.size},#{item.pn},#{item.po},#{item.fc},#{item.qty})
</foreach>
</insert>
<select id="queryjnP7sj" resultMap="BaseResultMap">
select * from jnsp7xtm_dqsj
where 1=1
......@@ -135,4 +142,43 @@
FROM
jnsp7xtm_dqsj
</select>
<select id="queryCustomer" resultMap="BaseResultMap">
SELECT
cust_code AS cc,
cust_name AS cn,
cust_group,
cust_group2,
cust_rt1,
cust_io,
cust_newpic,
cust_group1,
cust_rout,
cust_rt2,
cust_addr,
cust_g0,
cust_g20,
cust_g30,
cust_g201,
cust_save,
cust_stype,
cust_g1,
cust_yj,
cust_yj2,
cust_yj3,
cust_gc
FROM
b_customer
WHERE
del_flag = '0'
AND cust_code = #{cc}
</select>
<select id="querySypnByPn" resultType="java.lang.String">
SELECT
sypn
FROM
b_pn_sypn
WHERE
del_flag = '0'
and pn = #{pn}
</select>
</mapper>
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