feat(management): 添加销齿链型号数据导入功能

- 新增 DefaultExcelListener、DefaultExcelResult、ExcelListener 和 ExcelResult 类用于处理 Excel 导入
- 在 PcRigidChainController 中添加 importVariableData 方法处理导入逻辑
- 在 PcRigidChainMapper 和 PcRigidChainServiceImpl 中添加批量更新方法支持导入数据的批量插入
- 优化了导入流程,支持根据文件名自动识别类型,并处理不同轴向的数据
This commit is contained in:
tzy 2025-05-13 13:19:26 +08:00
parent 05a4a7c062
commit 461a22564b
17 changed files with 1080 additions and 122 deletions

View File

@ -35,6 +35,7 @@
<poi.version>3.17</poi.version>
<oshi.version>3.9.1</oshi.version>
<velocity.version>1.7</velocity.version>
</properties>
<dependencies>
@ -50,7 +51,16 @@
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency> -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>4.0.3</version>
</dependency>
<!-- 汉字转拼音 pinyin4j -->
<dependency>
<groupId>com.belerweb</groupId>

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.utils;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
import java.util.Set;
/**
* Validator 校验框架工具
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ValidatorUtils {
private static final Validator VALID = SpringUtils.getBean(Validator.class);
public static <T> void validate(T object, Class<?>... groups) {
Set<ConstraintViolation<T>> validate = VALID.validate(object, groups);
if (!validate.isEmpty()) {
throw new ConstraintViolationException("参数校验异常", validate);
}
}
}

View File

@ -0,0 +1,95 @@
package com.ruoyi.common.utils.listener;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.ruoyi.common.utils.ValidatorUtils;
import com.ruoyi.common.utils.sql.JsonUtils;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.Map;
import java.util.Set;
@Slf4j
@NoArgsConstructor
public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements ExcelListener<T>{
/**
* 是否Validator检验默认为是
*/
private Boolean isValidate = Boolean.TRUE;
/**
* excel 表头数据
*/
private Map<Integer, String> headMap;
/**
* 导入回执
*/
private ExcelResult<T> excelResult;
public DefaultExcelListener(boolean isValidate) {
this.excelResult = new DefaultExcelResult<>();
this.isValidate = isValidate;
}
@Override
public void onException(Exception exception, AnalysisContext context) throws Exception {
String errMsg = null;
if (exception instanceof ExcelDataConvertException) {
// 如果是某一个单元格的转换异常 能获取到具体行号
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
Integer rowIndex = excelDataConvertException.getRowIndex();
Integer columnIndex = excelDataConvertException.getColumnIndex();
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
if (log.isDebugEnabled()) {
log.error(errMsg);
}
}
if (exception instanceof ConstraintViolationException) {
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
}
excelResult.getErrorList().add(errMsg);
throw new ExcelAnalysisException(errMsg);
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
this.headMap = headMap;
log.debug("解析到一条表头数据: {}", JsonUtils.toJsonString(headMap));
}
@Override
public void invoke(T data, AnalysisContext context) {
if (isValidate) {
ValidatorUtils.validate(data);
}
excelResult.getList().add(data);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
log.debug("所有数据解析完成!");
}
@Override
public boolean hasNext(AnalysisContext context) {
return super.hasNext(context);
}
@Override
public ExcelResult<T> getExcelResult() {
return excelResult;
}
}

View File

@ -0,0 +1,74 @@
package com.ruoyi.common.utils.listener;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.utils.listener.ExcelResult;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* 默认excel返回对象
*
* @author Yjoioooo
* @author Lion Li
*/
public class DefaultExcelResult<T> implements ExcelResult<T> {
/**
* 数据对象list
*/
@Setter
private List<T> list;
/**
* 错误信息列表
*/
@Setter
private List<String> errorList;
public DefaultExcelResult() {
this.list = new ArrayList<>();
this.errorList = new ArrayList<>();
}
public DefaultExcelResult(List<T> list, List<String> errorList) {
this.list = list;
this.errorList = errorList;
}
public DefaultExcelResult(ExcelResult<T> excelResult) {
this.list = excelResult.getList();
this.errorList = excelResult.getErrorList();
}
@Override
public List<T> getList() {
return list;
}
@Override
public List<String> getErrorList() {
return errorList;
}
/**
* 获取导入回执
*
* @return 导入回执
*/
@Override
public String getAnalysis() {
int successCount = list.size();
int errorCount = errorList.size();
if (successCount == 0) {
return "读取失败,未解析到数据";
} else {
if (errorCount == 0) {
return StrUtil.format("恭喜您,全部读取成功!共{}条", successCount);
} else {
return "";
}
}
}
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.common.utils.listener;
import com.alibaba.excel.read.listener.ReadListener;
/**
* Excel 导入监听
*
* @author tzy
*/
public interface ExcelListener<T> extends ReadListener<T> {
ExcelResult<T> getExcelResult();
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.common.utils.listener;
import java.util.List;
/**
* excel返回对象
*
* @author Lion Li
*/
public interface ExcelResult<T> {
/**
* 对象列表
*/
List<T> getList();
/**
* 错误列表
*/
List<String> getErrorList();
/**
* 导入回执
*/
String getAnalysis();
}

View File

@ -0,0 +1,113 @@
package com.ruoyi.common.utils.sql;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* JSON 工具类
*
* @author 芋道源码
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class JsonUtils {
private static final ObjectMapper OBJECT_MAPPER = SpringUtils.getBean(ObjectMapper.class);
public static ObjectMapper getObjectMapper() {
return OBJECT_MAPPER;
}
public static String toJsonString(Object object) {
if (ObjectUtil.isNull(object)) {
return null;
}
try {
return OBJECT_MAPPER.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, Class<T> clazz) {
if (StringUtils.isEmpty(text)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(text, clazz);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
if (ArrayUtil.isEmpty(bytes)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(bytes, clazz);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, TypeReference<T> typeReference) {
if (StringUtils.isBlank(text)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(text, typeReference);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static Dict parseMap(String text) {
if (StringUtils.isBlank(text)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
} catch (MismatchedInputException e) {
// 类型不匹配说明不是json
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static List<Dict> parseArrayMap(String text) {
if (StringUtils.isBlank(text)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Dict.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static <T> List<T> parseArray(String text, Class<T> clazz) {
if (StringUtils.isEmpty(text)) {
return new ArrayList<>();
}
try {
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -17,42 +19,53 @@ public class BaseEntity implements Serializable
private static final long serialVersionUID = 1L;
/** 搜索值 */
@ExcelIgnore
private String searchValue;
/** 创建者 */
@ExcelIgnore
private String createBy;
/** 创建时间 */
@ExcelIgnore
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者 */
@ExcelIgnore
private String updateBy;
/** 更新时间 */
@ExcelIgnore
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
@ExcelIgnore
private String remark;
/** 开始时间 */
@JsonIgnore
@ExcelIgnore
private String beginTime;
/** 结束时间 */
@JsonIgnore
@ExcelIgnore
private String endTime;
/** 开始时间 */
@ExcelIgnore
@JsonIgnore
private String beginTimeTwo;
/** 结束时间 */
@ExcelIgnore
@JsonIgnore
private String endTimeTwo;
/** 请求参数 */
@ExcelIgnore
private Map<String, Object> params;
public String getSearchValue()

View File

@ -177,7 +177,7 @@ public class CwAttendanceRecordDetailController extends BaseController
//判断list中最后一条数据如果最后一条数据的打卡类型为 上班卡单班制上班卡双班制上班卡三班制和加班卡则返回 下班卡权限和撤销权限
CwAttendanceRecordDetail attendanceRecordDetail = list.get(list.size()-1);
if(null!=attendanceRecordDetail&&null!=attendanceRecordDetail.getButtonType()&&(attendanceRecordDetail.getButtonType().equals("上班卡(单班制)")||attendanceRecordDetail.getButtonType().equals("上班卡(双班制)")||attendanceRecordDetail.getButtonType().equals("上班卡(三班制)")||attendanceRecordDetail.getButtonType().equals("加班卡"))){
cardV.setResult(0);
cardV.setResult(0);
cardV.setMsg("验证通过");
//下班卡和撤销权限
cardD.setButton("000011000");

View File

@ -1,15 +1,31 @@
package com.ruoyi.project.management.controller;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.listener.DefaultExcelListener;
import com.ruoyi.common.utils.sql.JsonUtils;
import com.ruoyi.project.management.domain.*;
import com.ruoyi.project.management.domain.vo.PcRigidChainVO;
import com.ruoyi.project.management.mapper.PcRigidChainMapper;
import com.ruoyi.project.management.service.IImMaterialGroupService;
import com.ruoyi.project.management.service.IImMaterialTypeService;
import com.ruoyi.project.management.service.IImMeteringUnitService;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -37,6 +53,8 @@ import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
import javax.servlet.ReadListener;
/**
* 销齿链型号Controller
*
@ -45,8 +63,7 @@ import com.ruoyi.framework.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/management/rigidChain")
public class PcRigidChainController extends BaseController
{
public class PcRigidChainController extends BaseController {
@Autowired
private IPcRigidChainService pcRigidChainService;
//用户标识信息
@ -60,14 +77,15 @@ public class PcRigidChainController extends BaseController
//物料分组
@Autowired
private IImMaterialGroupService imMaterialGroupService;
@Autowired
private PcRigidChainMapper pcRigidChainMapper;
/**
* 查询销齿链型号列表(报价时查询型号去重)
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:list')")
@GetMapping("/getTypeList")
public TableDataInfo getTypeList()
{
public TableDataInfo getTypeList() {
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainByTypeList();
return getDataTable(list);
}
@ -77,8 +95,7 @@ public class PcRigidChainController extends BaseController
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:list')")
@GetMapping("/getJourneyList")
public TableDataInfo getJourneyList(String type)
{
public TableDataInfo getJourneyList(String type) {
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainByJourneyList(type);
return getDataTable(list);
}
@ -88,8 +105,7 @@ public class PcRigidChainController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('management:rigidChain:list')")
@GetMapping("/list")
public TableDataInfo list(PcRigidChain pcRigidChain)
{
public TableDataInfo list(PcRigidChain pcRigidChain) {
startPage();
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
return getDataTable(list);
@ -98,23 +114,123 @@ public class PcRigidChainController extends BaseController
/**
* 导出销齿链型号列表
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:export')")
@Log(title = "销齿链型号", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(PcRigidChain pcRigidChain)
{
public AjaxResult export(PcRigidChain pcRigidChain) {
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
ExcelUtil<PcRigidChain> util = new ExcelUtil<PcRigidChain>(PcRigidChain.class);
ExcelUtil<PcRigidChain> util = new ExcelUtil<>(PcRigidChain.class);
return util.exportExcel(list, "rigidChain");
}
@PreAuthorize("@ss.hasPermi('management:rigidChain:importVariableData')")
@PostMapping("/importVariableData")
public AjaxResult importVariableData(@RequestParam("file") MultipartFile file) throws Exception {
if (file == null || file.isEmpty()) {
return AjaxResult.error("上传文件不能为空");
}
// 将输入流转为字节数组以便多次读取
byte[] fileBytes = file.getBytes();
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || originalFilename.isEmpty()) {
return AjaxResult.error("文件名不能为空");
}
String type = "";
if (originalFilename.contains("30D")) {
type = "30D";
} else if (originalFilename.contains("30S")) {
type = "30S";
} else if (originalFilename.contains("35E_R")) {
type = "35E";
} else if (originalFilename.contains("40R")) {
type = "40R";
} else if (originalFilename.contains("40S")) {
type = "40S";
} else if (originalFilename.contains("60R")) {
type = "60R";
} else if (originalFilename.contains("80R")) {
type = "80R";
} else if (originalFilename.contains("100R")) {
type = "100R";
} else if (originalFilename.contains("125R")) {
type = "125R";
}
//每个产品都会有 ,,+
List<String> AxialDirection = Arrays.asList("R", "L", "L+R");
ExcelReaderBuilder read = EasyExcel.read(new ByteArrayInputStream(fileBytes));
for (ReadSheet readSheet : read.build().excelExecutor().sheetList()) {
DefaultExcelListener<PcRigidChainVO> excelListener = new DefaultExcelListener<>(true);
EasyExcel.read(new ByteArrayInputStream(fileBytes), PcRigidChainVO.class, excelListener)
.excelType(ExcelTypeEnum.XLS)
.sheet(readSheet.getSheetNo())
.headRowNumber(4)
.doRead();
List<PcRigidChainVO> list = excelListener.getExcelResult().getList();
List<PcRigidChain> pcRigidChainsToUpdate = new ArrayList<>();
// 批量查询数据库中的记录
List<PcRigidChain> chains = pcRigidChainMapper.selectPcRigidChainByType(type);
Map<String, PcRigidChain> chainMap = chains.stream()
.collect(Collectors.toMap(c -> c.getTypeName() + "_" + c.getAxialDirection(), c -> c));
for (String s : AxialDirection) {
for (PcRigidChainVO pcRigidChainVO : list) {
Long vOne = pcRigidChainVO.getVOne();
String sheetName = readSheet.getSheetName();
String box = "";
if (sheetName != null && sheetName.contains("单层") ) {
box = "S";
} else if (sheetName != null && sheetName.contains("双层") ) {
box = "D";
} else if (sheetName != null && sheetName.contains("三层")) {
box = "T";
}
String typeName = type + "/" + s + "-" + vOne + "/" + box;
logger.debug("此物料的完整图号:=====================>{}", typeName);
// 从缓存中查找
PcRigidChain dbChain = chainMap.get(typeName + "_" + s);
if (dbChain != null) {
BeanUtil.copyProperties(pcRigidChainVO, dbChain,"id");
dbChain.setJourney(vOne);
dbChain.setTypeName(typeName);
dbChain.setType(type);
dbChain.setBox(box);
dbChain.setAxialDirection(s);
// dbChain.setUpdateBy(SecurityUtils.getUsername());
dbChain.setCreateTime(new Date());
pcRigidChainsToUpdate.add(dbChain);
}
}
}
if (!pcRigidChainsToUpdate.isEmpty()) {
for (PcRigidChain pcRigidChain : pcRigidChainsToUpdate) {
int i = pcRigidChainMapper.updatePcRigidChain(pcRigidChain);
if (i > 0) {
logger.debug("物料:{}更新成功!!", pcRigidChain.getTypeName());
} else {
logger.debug("物料:{}更新失败!!", pcRigidChain.getTypeName());
}
}
}else {
return AjaxResult.error("没有找到要更新的数据");
}
}
return AjaxResult.success("导入成功!!");
}
/**
* 获取销齿链型号详细信息
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(pcRigidChainService.selectPcRigidChainById(id));
}
@ -124,27 +240,27 @@ public class PcRigidChainController extends BaseController
@PreAuthorize("@ss.hasPermi('management:rigidChain:add')")
@Log(title = "销齿链型号", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PcRigidChain pcRigidChain){
//防止出现null指针异常
if(null==pcRigidChain){
return AjaxResult.error(600,"参数不能为空,请传参");
}
//型号名称为必填,校验非空
if(null==pcRigidChain.getTypeName()||"".equals(pcRigidChain.getTypeName())){
return AjaxResult.error(10,"请输入型号名称");
}
//拼接型号全称
public AjaxResult add(@RequestBody PcRigidChain pcRigidChain) {
//防止出现null指针异常
if (null == pcRigidChain) {
return AjaxResult.error(600, "参数不能为空,请传参");
}
//型号名称为必填,校验非空
if (null == pcRigidChain.getTypeName() || "".equals(pcRigidChain.getTypeName())) {
return AjaxResult.error(10, "请输入型号名称");
}
//拼接型号全称
// String typeName = pcRigidChain.getType()+"/"+pcRigidChain.getAxialDirection()+"-"+pcRigidChain.getJourney()+"/"+pcRigidChain.getBox();
//判断型号是否存在
PcRigidChain rigidChain = pcRigidChainService.selectPcRigidChainByTypeName(pcRigidChain.getTypeName());
if(null!=rigidChain){
return AjaxResult.error(11, "型号名称已存在");
}
//行程
pcRigidChain.setJourney(pcRigidChain.getvOne());
//产品名称
//pcRigidChain.setProductName("销齿链");
pcRigidChain.setDelFlag(0L);
//判断型号是否存在
PcRigidChain rigidChain = pcRigidChainService.selectPcRigidChainByTypeName(pcRigidChain.getTypeName());
if (null != rigidChain) {
return AjaxResult.error(11, "型号名称已存在");
}
//行程
pcRigidChain.setJourney(pcRigidChain.getvOne());
//产品名称
//pcRigidChain.setProductName("销齿链");
pcRigidChain.setDelFlag(0L);
return toAjax(pcRigidChainService.insertPcRigidChain(pcRigidChain));
}
@ -154,15 +270,15 @@ public class PcRigidChainController extends BaseController
@PreAuthorize("@ss.hasPermi('management:rigidChain:edit')")
@Log(title = "销齿链型号", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PcRigidChain pcRigidChain){
if(null==pcRigidChain.getTypeName()||"".equals(pcRigidChain.getTypeName())){
return AjaxResult.error(10,"请输入型号名称");
}
//判断型号是否存在
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
if(list.size()>0){
return AjaxResult.error(11, "型号名称已存在");
}
public AjaxResult edit(@RequestBody PcRigidChain pcRigidChain) {
if (null == pcRigidChain.getTypeName() || "".equals(pcRigidChain.getTypeName())) {
return AjaxResult.error(10, "请输入型号名称");
}
//判断型号是否存在
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
if (list.size() > 0) {
return AjaxResult.error(11, "型号名称已存在");
}
return toAjax(pcRigidChainService.updatePcRigidChain(pcRigidChain));
}
@ -171,9 +287,8 @@ public class PcRigidChainController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('management:rigidChain:remove')")
@Log(title = "销齿链型号", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(pcRigidChainService.deletePcRigidChainByIds(ids));
}
@ -184,18 +299,18 @@ public class PcRigidChainController extends BaseController
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:list')")
@RequestMapping("/getRigidChain")
public AjaxResult selectRigidChain(PcRigidChain pcRigidChain){
if(null==pcRigidChain){
return AjaxResult.error("参数不能为空,请传参");
}
if(null==pcRigidChain.getTypeName()||"".equals(pcRigidChain.getTypeName().trim())){
return AjaxResult.error("参数不能为空,请传参");
}
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
if(list.size()>0){
return AjaxResult.error("型号名称已存在");
}
return AjaxResult.success();
public AjaxResult selectRigidChain(PcRigidChain pcRigidChain) {
if (null == pcRigidChain) {
return AjaxResult.error("参数不能为空,请传参");
}
if (null == pcRigidChain.getTypeName() || "".equals(pcRigidChain.getTypeName().trim())) {
return AjaxResult.error("参数不能为空,请传参");
}
List<PcRigidChain> list = pcRigidChainService.selectPcRigidChainList(pcRigidChain);
if (list.size() > 0) {
return AjaxResult.error("型号名称已存在");
}
return AjaxResult.success();
}
/**
@ -204,16 +319,16 @@ public class PcRigidChainController extends BaseController
*/
// @PreAuthorize("@ss.hasPermi('management:rigidChain:list')")
@RequestMapping("/getPcRigidChainByTypeName")
public AjaxResult getPcRigidChainByTypeName(String typeName){
//获取当前登录用户信息,查询当前登录用户的vip等级
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
public AjaxResult getPcRigidChainByTypeName(String typeName) {
//获取当前登录用户信息,查询当前登录用户的vip等级
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
//获取用户vip的等级
double vipLevel = user.getVipLevel();
//根据型号全称查询型号信息
PcRigidChain rigidChain = pcRigidChainService.selectPcRigidChainByTypeName(typeName);
if(null==rigidChain){
return AjaxResult.error("暂无此型号");
if (null == rigidChain) {
return AjaxResult.error("暂无此型号");
}
rigidChain.setVipLevel(vipLevel);
return AjaxResult.success(rigidChain);
@ -224,41 +339,41 @@ public class PcRigidChainController extends BaseController
*/
@RequestMapping("/uploadLableNumber")
@ResponseBody
public AjaxResult uploadLableNumber(@RequestParam("file") MultipartFile filePath){
String originalFilename = filePath.getOriginalFilename();
//校验文件后缀
String postfix = originalFilename.substring(originalFilename.length()-3);
String substring = originalFilename.substring(originalFilename.length()-4);
//判断是否是xlsx文件或xls文件
if("xls".equals(postfix)||"xlsx".equals(substring)){
try {
InputStream is = filePath.getInputStream();
byte[] bytes = new byte[is.available()];
is.read(bytes);
File file = new File("D:/lableExcel/"+originalFilename);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(bytes);
bos.flush();
is.close();
fos.close();
bos.close();
File files = new File(file.getAbsolutePath());
ArrayList<ArrayList<Object>> result = ExcelU.readExcel(files);
for (int i = 1; i < result.size(); i++) {
for (int j = 1; j < result.get(i).size(); j++) {
PcRigidChain rigidChain = pcRigidChainService.selectPcRigidChainByTypeName("XCL"+result.get(i).get(1).toString());
if(null!=rigidChain){
rigidChain.setLableNumber(result.get(i).get(0).toString());
pcRigidChainService.updatePcRigidChain(rigidChain);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success("文件上传成功");
}
return AjaxResult.error("非excel文件不允许上传");
public AjaxResult uploadLableNumber(@RequestParam("file") MultipartFile filePath) {
String originalFilename = filePath.getOriginalFilename();
//校验文件后缀
String postfix = originalFilename.substring(originalFilename.length() - 3);
String substring = originalFilename.substring(originalFilename.length() - 4);
//判断是否是xlsx文件或xls文件
if ("xls".equals(postfix) || "xlsx".equals(substring)) {
try {
InputStream is = filePath.getInputStream();
byte[] bytes = new byte[is.available()];
is.read(bytes);
File file = new File("D:/lableExcel/" + originalFilename);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(bytes);
bos.flush();
is.close();
fos.close();
bos.close();
File files = new File(file.getAbsolutePath());
ArrayList<ArrayList<Object>> result = ExcelU.readExcel(files);
for (int i = 1; i < result.size(); i++) {
for (int j = 1; j < result.get(i).size(); j++) {
PcRigidChain rigidChain = pcRigidChainService.selectPcRigidChainByTypeName("XCL" + result.get(i).get(1).toString());
if (null != rigidChain) {
rigidChain.setLableNumber(result.get(i).get(0).toString());
pcRigidChainService.updatePcRigidChain(rigidChain);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success("文件上传成功");
}
return AjaxResult.error("非excel文件不允许上传");
}
}

View File

@ -2033,7 +2033,7 @@ public class PwProductionBillController extends BaseController {
}else{
arr += "F:/20"+code.substring(2,4);
}
arr += "/product/";
arr += "/";
//删除目录和文件夹
DeleteFile.deleteDirectory(arr+code+"/zip");
//创建打包的文件夹,如果存在先删除再创建

View File

@ -38,13 +38,6 @@ public class PcRigidChain extends BaseEntity
@Excel(name = "物料编码")
private String materialCode;
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
/** 轴向 */
@Excel(name = "轴向")
@ -207,6 +200,7 @@ public class PcRigidChain extends BaseEntity
/** 导向条长度2数量 */
@Excel(name = "导向条长度2数量")
//@Excel(name = "导向条2数量")
private Long vThirteen;
/** 导向条长度3 */
@ -215,6 +209,7 @@ public class PcRigidChain extends BaseEntity
/** 导向条长度3数量 */
@Excel(name = "导向条长度3数量")
//@Excel(name = "导向条3数量")
private Long vFifteen;
/** 孔位总长1 */
@ -370,11 +365,11 @@ public class PcRigidChain extends BaseEntity
private Long vFiftyThree;
/** 重量 */
// @Excel(name = "重量")
@Excel(name = "铝箱1重量")
private Double gOne;
/** 重量 */
// @Excel(name = "重量")
@Excel(name = "铝箱2重量")
private Double gTwo;
/** 重量 */
@ -386,15 +381,15 @@ public class PcRigidChain extends BaseEntity
private Double gFour;
/** 重量 */
// @Excel(name = "")
@Excel(name = "导向条1单")
private Double gFive;
/** 重量 */
// @Excel(name = "")
@Excel(name = "导向条2单")
private Double gSix;
/** 重量 */
// @Excel(name = "")
@Excel(name = "导向条3单")
private Double gSeven;
/** 重量 */
@ -453,6 +448,13 @@ public class PcRigidChain extends BaseEntity
private String spline;
private Long number;
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public void setId(Long id)
{
this.id = id;

View File

@ -0,0 +1,452 @@
package com.ruoyi.project.management.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.framework.web.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 销齿链型号对象 pc_rigid_chain
*
* @author zhukangchao
* @date 2020-10-22
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class PcRigidChainVO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 类型 */
@ExcelProperty("类型")
private String type;
/** 型号全称 */
@ExcelProperty("型号")
private String typeName;
/** 产品id */
@ExcelProperty("产品id")
private Long productId;
/** 产品名称 */
@ExcelProperty("产品名称")
private String productName;
/** 物料编码 */
@ExcelProperty("物料编码")
private String materialCode;
/** 轴向 */
@ExcelProperty("轴向")
private String axialDirection;
/** 箱体 */
@ExcelProperty("箱体")
private String box;
/** 行程mm */
//@ExcelProperty("{V1}")
private Long journey;
/** 标记号 */
@ExcelProperty("标记号")
private String lableNumber;
/** L1mm */
@ExcelProperty("L1")
private Long lOne;
/** L2mm */
@ExcelProperty("L2")
private Long lTwo;
/** L3mm */
@ExcelProperty("L3")
private Long lThree;
/** 总重量 */
@ExcelProperty("总重量")
private Long sumWeight;
/** 链条自重 */
@ExcelProperty("链条自重")
private Long chainWeight;
/** 动载荷KN */
@ExcelProperty("动载荷")
private Long dynamicLoad;
/** 静载荷KN */
@ExcelProperty("静载荷")
private Long deadLoad;
/** 每转上升高度mm */
@ExcelProperty("每转上升高度")
private Long riseInHeightPerRevolution;
/** 速度mm/s */
@ExcelProperty("速度")
private Double speed;
/** 系统效率(% */
@ExcelProperty("系统效率")
private Long efficiency;
/** 链条节距mm */
@ExcelProperty("链条节距")
private Long chainPitch;
/** 节圆半径mm */
@ExcelProperty("节圆半径")
private Long pitchRadius;
/** 最低高度mm */
@ExcelProperty("最低高度")
private Long minimumAltitude;
/** 一米链条自重Kg/m */
@ExcelProperty("一米链条自重")
private Double singleMeterChainWeight;
/** 驱动箱重量Kg */
@ExcelProperty("驱动箱重量")
private Long drivingBoxWeight;
/** 链箱重量Kg/m */
@ExcelProperty("链箱重量")
private Double chainBoxWeight;
/** 单价 */
@ExcelProperty("单价")
private Double univalence;
/** 图片 */
@ExcelProperty("图片")
private String picture;
/** 部件id集合 */
@ExcelProperty("部件id集合")
private String partId;
/** 备用字段1 */
@ExcelProperty("备用字段1")
private String sparedOne;
/** 备用字段2 */
@ExcelProperty("备用字段2")
private String sparedTwo;
/** 备用字段3 */
@ExcelProperty("备用字段3")
private Long sparedThree;
/** 备用字段4 */
@ExcelProperty("备用字段4")
private Long sparedFour;
/** 删除标记0未删除1已删除 */
private Long delFlag;
/** 行程 */
@ExcelProperty("{V1}")
private Long vOne;
/** 设备总长 */
@ExcelProperty("{V2}")
private Long vTwo;
/** 地脚位置1 */
@ExcelProperty("{V3}")
private Long vThree;
/** 地脚位置2 */
@ExcelProperty("{V4}")
private Long vFour;
/** 箱体装配长度 */
@ExcelProperty("{V5}")
private Long vFive;
/** 箱体地脚位置1 */
@ExcelProperty("{V6}")
private Long vSix;
/** 箱体地脚位置2 */
@ExcelProperty("{V7}")
private Long vSeven;
/** 铝箱长度1 */
@ExcelProperty("{V8}")
private Long vEight;
/** 铝箱长度2 */
@ExcelProperty("{V9}")
private Long vNine;
/** 导向条长度1 */
@ExcelProperty("{V10}")
private Long vTen;
/** 导向条长度1数量 */
@ExcelProperty("{V11}")
private Long vEleven;
/** 导向条长度2 */
@ExcelProperty("{V12}")
private Long vTwelve;
/** 导向条长度2数量 */
@ExcelProperty("{V13}")
//@Excel(name = "导向条2数量")
private Long vThirteen;
/** 导向条长度3 */
@ExcelProperty("{V14}")
private Long vFourteen;
/** 导向条长度3数量 */
@ExcelProperty("{V15}")
//@Excel(name = "导向条3数量")
private Long vFifteen;
/** 孔位总长1 */
@ExcelProperty("{V16}")
private Long vSixteen;
/** 间隔数量1 */
@ExcelProperty("{V17}")
private Long vSeveteen;
/** 孔位总长2 */
@ExcelProperty("{V18}")
private Long vEighteen;
/** 间隔数量2 */
@ExcelProperty("{V19}")
private Long vNineteen;
/** 铆钉数量 */
@ExcelProperty("{V20}")
private Long vTwenty;
/** 待定义 */
@ExcelProperty("{V21}")
private Long vTwentyOne;
/** 待定义 */
@ExcelProperty("{V22}")
private Long vTwentyTwo;
/** 待定义 */
@ExcelProperty("{V23}")
private Long vTwentyThree;
/** 待定义 */
@ExcelProperty("{V24}")
private Long vTwentyFour;
/** 待定义 */
@ExcelProperty("{V25}")
private Long vTwentyFive;
/** 待定义 */
@ExcelProperty("{V26}")
private Long vTwentySix;
/** 待定义 */
@ExcelProperty("{V27}")
private Long vTwentySeven;
/** 待定义 */
@ExcelProperty("{V28}")
private Long vTwentyEight;
/** 待定义 */
@ExcelProperty("{V29}")
private Long vTwentyNine;
/** 待定义 */
@ExcelProperty("{V30}")
private Long vThirty;
/** 待定义 */
@ExcelProperty("{V31}")
private Long vThirtyOne;
/** 待定义 */
@ExcelProperty("{V32}")
private Long vThirtyTwo;
/** 待定义 */
@ExcelProperty("{V33}")
private Long vThirtyThree;
/** 待定义 */
@ExcelProperty("{V34}")
private Long vThirtyFour;
/** 待定义 */
@ExcelProperty("{V35}")
private Long vThirtyFive;
/** 待定义 */
@ExcelProperty("{V36}")
private Long vThirtySix;
/** 待定义 */
@ExcelProperty("{V37}")
private Long vThirtySeven;
/** 待定义 */
@ExcelProperty("{V38}")
private Long vThirtyEight;
/** 待定义 */
@ExcelProperty("{V39}")
private Long vThirtyNine;
/** 待定义 */
@ExcelProperty("{V40}")
private Long vForty;
/** X1 */
@ExcelProperty("{V41}")
private Long vFortyOne;
/** X2 */
@ExcelProperty("{V42}")
private Long vFortyTwo;
/** X3 */
@ExcelProperty("{V43}")
private Long vFortyThree;
/** X4 */
@ExcelProperty("{V44}")
private Long vFortyFour;
/** X5 */
@ExcelProperty("{V45}")
private Long vFortyFive;
/** X6 */
@ExcelProperty("{V46}")
private Long vFortySix;
/** X7 */
@ExcelProperty("{V48}")
private Long vFortySeven;
/** X8 */
@ExcelProperty("V48")
private Long vFortyEight;
/** X9 */
@ExcelProperty("{V49}")
private Long vFortyNine;
/** X10 */
@ExcelProperty("{V50}")
private Long vFifty;
/** X11 */
@ExcelProperty("{V51}")
private Long vFiftyOne;
/** X12 */
@ExcelProperty("{V52}")
private Long vFiftyTwo;
/** X13 */
@ExcelProperty("{V53}")
private Long vFiftyThree;
/** 重量 */
@ExcelProperty("{G1}")
private Double gOne;
/** 重量 */
@ExcelProperty("{G2}")
private Double gTwo;
/** 重量 */
@ExcelProperty("{G3}")
private Double gThree;
/** 重量 */
@ExcelProperty("{G4}")
private Double gFour;
/** 重量 */
@ExcelProperty("{G5}")
private Double gFive;
/** 重量 */
@ExcelProperty("{G6}")
private Double gSix;
/** 重量 */
@ExcelProperty("{G7}")
private Double gSeven;
/** 重量 */
@ExcelProperty("{G8}")
private Double gEight;
/** 重量 */
@ExcelProperty("{G9}")
private Double gNine;
/** 重量 */
@ExcelProperty("{G10}")
private Double gTen;
/** 重量 */
@ExcelProperty("{G11}")
private Double gEleven;
/** 重量 */
@ExcelProperty("{G12}")
private Double gTwelve;
/** 重量 */
@ExcelProperty("{G13}")
private Double gThirteen;
/** 重量 */
@ExcelProperty("{G14}")
private Double gFourteen;
/** 重量 */
@ExcelProperty("{G15}")
private Double gFifteen;
/** 重量 */
@ExcelProperty("{G16}")
private Double gSixteen;
/** 重量 */
@ExcelProperty("{G17}")
private Double gSeveteen;
/** 重量 */
@ExcelProperty("{G18}")
private Double gEighteen;
/** 重量 */
@ExcelProperty("{G19}")
private Double gNineteen;
/** 重量 */
@ExcelProperty("{G20}")
private Double gTwenty;
private Double vipLevel;
private String spline;
private Long number;
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.project.management.mapper;
import java.util.List;
import com.ruoyi.project.management.domain.PcRigidChain;
import com.ruoyi.project.management.domain.vo.PcRigidChainVO;
/**
* 销齿链型号Mapper接口
@ -42,6 +43,7 @@ public interface PcRigidChainMapper
* @return 结果
*/
public int updatePcRigidChain(PcRigidChain pcRigidChain);
public int updatePcRigidChainVO(PcRigidChainVO pcRigidChain);
/**
* 删除销齿链型号
@ -80,4 +82,6 @@ public interface PcRigidChainMapper
public List<PcRigidChain> selectPcRigidChainByJourneyList(String type);
public List<PcRigidChain> selectPcRigidChainByType(String type);
int updateBatchById(List<PcRigidChain> pcRigidChainsToUpdate);
}

View File

@ -78,4 +78,6 @@ public interface IPcRigidChainService
public List<PcRigidChain> selectPcRigidChainByJourneyList(String type);
public List<PcRigidChain> selectPcRigidChainByType(String type);
int updateBatchById(List<PcRigidChain> pcRigidChainsToUpdate);
}

View File

@ -15,7 +15,7 @@ import com.ruoyi.project.management.service.IPcRigidChainService;
* @date 2020-06-09
*/
@Service
public class PcRigidChainServiceImpl implements IPcRigidChainService
public class PcRigidChainServiceImpl implements IPcRigidChainService
{
@Autowired
private PcRigidChainMapper pcRigidChainMapper;
@ -128,4 +128,10 @@ public class PcRigidChainServiceImpl implements IPcRigidChainService
return list;
}
@Override
public int updateBatchById(List<PcRigidChain> pcRigidChainsToUpdate) {
//批量更新
return pcRigidChainMapper.updateBatchById(pcRigidChainsToUpdate);
}
}

View File

@ -652,5 +652,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPcRigidChainVo" />
where type = #{type} and del_flag = 0
</select>
<!--根据id 批量更新 -->
<update id="updateBatchById" parameterType="java.util.List">
update pc_rigid_chain
</update>
</mapper>