表单的导出

This commit is contained in:
Machengtianjiang 2021-01-05 11:29:25 +08:00
parent b562da3b80
commit e65f914663
41 changed files with 320 additions and 462 deletions

View File

@ -5,9 +5,8 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.winery.domain.WineryMauser; import com.ruoyi.winery.domain.winery.WineryMauser;
import com.ruoyi.winery.service.IWineryMauserService; import com.ruoyi.winery.service.IWineryMauserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@ -46,13 +46,12 @@ public class NewsContentController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('news:news_content:list')") @PreAuthorize("@ss.hasPermi('news:news_content:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(NewsContent newsContent) public TableDataInfo list(UsernamePasswordAuthenticationToken token, NewsContent newsContent) {
{
startPage(); startPage();
LambdaQueryWrapper<NewsContent> lqw = Wrappers.lambdaQuery(newsContent); LambdaQueryWrapper<NewsContent> lqw = Wrappers.lambdaQuery(newsContent);
if (newsContent.getDeptId() != null){
lqw.eq(NewsContent::getDeptId ,newsContent.getDeptId()); lqw.eq(NewsContent::getDeptId, getDeptId(token));
}
if (StringUtils.isNotBlank(newsContent.getNewsTitle())) { if (StringUtils.isNotBlank(newsContent.getNewsTitle())) {
lqw.eq(NewsContent::getNewsTitle, newsContent.getNewsTitle()); lqw.eq(NewsContent::getNewsTitle, newsContent.getNewsTitle());
} }

View File

@ -8,7 +8,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.component.MiniComponent; import com.ruoyi.winery.component.MiniComponent;
import com.ruoyi.winery.domain.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.ruoyi.winery.enums.IrrigationTypeEnum; import com.ruoyi.winery.enums.IrrigationTypeEnum;
import com.ruoyi.winery.enums.SoilTypeEnum; import com.ruoyi.winery.enums.SoilTypeEnum;
import com.ruoyi.winery.enums.WineryStatusEnum; import com.ruoyi.winery.enums.WineryStatusEnum;

View File

@ -1,21 +1,15 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import java.security.Principal;
import java.util.List; import java.util.List;
import java.util.Arrays; import java.util.Arrays;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -28,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.ruoyi.winery.service.IWineryCompanyRecordService; import com.ruoyi.winery.service.IWineryCompanyRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryFoodSafety; import com.ruoyi.winery.domain.winery.WineryFoodSafety;
import com.ruoyi.winery.service.IWineryFoodSafetyService; import com.ruoyi.winery.service.IWineryFoodSafetyService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryGoods; import com.ruoyi.winery.domain.winery.WineryGoods;
import com.ruoyi.winery.service.IWineryGoodsService; import com.ruoyi.winery.service.IWineryGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryGoodsSpec; import com.ruoyi.winery.domain.winery.WineryGoodsSpec;
import com.ruoyi.winery.service.IWineryGoodsSpecService; import com.ruoyi.winery.service.IWineryGoodsSpecService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryMauser; import com.ruoyi.winery.domain.winery.WineryMauser;
import com.ruoyi.winery.service.IWineryMauserService; import com.ruoyi.winery.service.IWineryMauserService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryOrders; import com.ruoyi.winery.domain.winery.WineryOrders;
import com.ruoyi.winery.service.IWineryOrdersService; import com.ruoyi.winery.service.IWineryOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.controller; package com.ruoyi.winery.controller.winery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,7 +22,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.winery.domain.WineryWineSpecDetail; import com.ruoyi.winery.domain.winery.WineryWineSpecDetail;
import com.ruoyi.winery.service.IWineryWineSpecDetailService; import com.ruoyi.winery.service.IWineryWineSpecDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.winery.enums.IrrigationTypeEnum; import com.ruoyi.winery.enums.IrrigationTypeEnum;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ruoyi.winery.domain; package com.ruoyi.winery.domain.winery;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryFoodSafety; import com.ruoyi.winery.domain.winery.WineryFoodSafety;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryGoods; import com.ruoyi.winery.domain.winery.WineryGoods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryGoodsSpec; import com.ruoyi.winery.domain.winery.WineryGoodsSpec;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryMauser; import com.ruoyi.winery.domain.winery.WineryMauser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryOrders; import com.ruoyi.winery.domain.winery.WineryOrders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.mapper; package com.ruoyi.winery.mapper;
import com.ruoyi.winery.domain.WineryWineSpecDetail; import com.ruoyi.winery.domain.winery.WineryWineSpecDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryFoodSafety; import com.ruoyi.winery.domain.winery.WineryFoodSafety;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryGoods; import com.ruoyi.winery.domain.winery.WineryGoods;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryGoodsSpec; import com.ruoyi.winery.domain.winery.WineryGoodsSpec;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryMauser; import com.ruoyi.winery.domain.winery.WineryMauser;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryOrders; import com.ruoyi.winery.domain.winery.WineryOrders;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -1,6 +1,6 @@
package com.ruoyi.winery.service; package com.ruoyi.winery.service;
import com.ruoyi.winery.domain.WineryWineSpecDetail; import com.ruoyi.winery.domain.winery.WineryWineSpecDetail;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryCompanyRecordMapper; import com.ruoyi.winery.mapper.WineryCompanyRecordMapper;
import com.ruoyi.winery.domain.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.ruoyi.winery.service.IWineryCompanyRecordService; import com.ruoyi.winery.service.IWineryCompanyRecordService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryFoodSafetyMapper; import com.ruoyi.winery.mapper.WineryFoodSafetyMapper;
import com.ruoyi.winery.domain.WineryFoodSafety; import com.ruoyi.winery.domain.winery.WineryFoodSafety;
import com.ruoyi.winery.service.IWineryFoodSafetyService; import com.ruoyi.winery.service.IWineryFoodSafetyService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryGoodsMapper; import com.ruoyi.winery.mapper.WineryGoodsMapper;
import com.ruoyi.winery.domain.WineryGoods; import com.ruoyi.winery.domain.winery.WineryGoods;
import com.ruoyi.winery.service.IWineryGoodsService; import com.ruoyi.winery.service.IWineryGoodsService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryGoodsSpecMapper; import com.ruoyi.winery.mapper.WineryGoodsSpecMapper;
import com.ruoyi.winery.domain.WineryGoodsSpec; import com.ruoyi.winery.domain.winery.WineryGoodsSpec;
import com.ruoyi.winery.service.IWineryGoodsSpecService; import com.ruoyi.winery.service.IWineryGoodsSpecService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryMauserMapper; import com.ruoyi.winery.mapper.WineryMauserMapper;
import com.ruoyi.winery.domain.WineryMauser; import com.ruoyi.winery.domain.winery.WineryMauser;
import com.ruoyi.winery.service.IWineryMauserService; import com.ruoyi.winery.service.IWineryMauserService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryOrdersMapper; import com.ruoyi.winery.mapper.WineryOrdersMapper;
import com.ruoyi.winery.domain.WineryOrders; import com.ruoyi.winery.domain.winery.WineryOrders;
import com.ruoyi.winery.service.IWineryOrdersService; import com.ruoyi.winery.service.IWineryOrdersService;
/** /**

View File

@ -3,7 +3,7 @@ package com.ruoyi.winery.service.impl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.winery.mapper.WineryWineSpecDetailMapper; import com.ruoyi.winery.mapper.WineryWineSpecDetailMapper;
import com.ruoyi.winery.domain.WineryWineSpecDetail; import com.ruoyi.winery.domain.winery.WineryWineSpecDetail;
import com.ruoyi.winery.service.IWineryWineSpecDetailService; import com.ruoyi.winery.service.IWineryWineSpecDetailService;
/** /**

View File

@ -18,6 +18,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -77,8 +78,12 @@ public class CosUtils {
COSObject cosObject = cosClient.getObject(getObjectRequest); COSObject cosObject = cosClient.getObject(getObjectRequest);
// 文件类型
response.setContentType(cosObject.getObjectMetadata().getContentType()); response.setContentType(cosObject.getObjectMetadata().getContentType());
// 文件大小
response.setContentLengthLong(cosObject.getObjectMetadata().getContentLength()); response.setContentLengthLong(cosObject.getObjectMetadata().getContentLength());
// 文件名
response.setHeader("Content-Disposition", "attachment;filename=" + cosObject.getKey());
OutputStream os = null; OutputStream os = null;
try { try {
os = response.getOutputStream(); os = response.getOutputStream();
@ -105,4 +110,22 @@ public class CosUtils {
} }
public String uploadFile(String type, String filename, File file) {
// 指定要上传到 COS 上对象键
String key = ReUtil.replaceAll(StrUtil.trim(Optional.of(filename).orElse(StrUtil.EMPTY)), SPECIAL_CHARACTERS, StrUtil.EMPTY);
// 生成 cos 客户端
COSClient cosClient = new COSClient(cosCredentials, clientConfig);
try {
PutObjectResult putObjectResult = cosClient.putObject(properties.getBucketName(), type + "/" + key, file);
} catch (Exception e) {
} finally {
cosClient.shutdown();
}
return type + "/" + key;
}
} }

View File

@ -1,10 +1,6 @@
package com.ruoyi.common.utils.poi; package com.ruoyi.common.utils.poi;
import java.io.File; import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@ -18,6 +14,9 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.common.utils.file.CosUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
@ -52,14 +51,14 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils; import com.ruoyi.common.utils.reflect.ReflectUtils;
import org.springframework.web.multipart.MultipartFile;
/** /**
* Excel相关处理 * Excel相关处理
* *
* @author ruoyi * @author ruoyi
*/ */
public class ExcelUtil<T> public class ExcelUtil<T> {
{
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
/** /**
@ -117,15 +116,15 @@ public class ExcelUtil<T>
*/ */
public Class<T> clazz; public Class<T> clazz;
public ExcelUtil(Class<T> clazz)
{ CosUtils cosUtils = SpringUtils.getBean(CosUtils.class);
public ExcelUtil(Class<T> clazz) {
this.clazz = clazz; this.clazz = clazz;
} }
public void init(List<T> list, String sheetName, Type type) public void init(List<T> list, String sheetName, Type type) {
{ if (list == null) {
if (list == null)
{
list = new ArrayList<T>(); list = new ArrayList<T>();
} }
this.list = list; this.list = list;
@ -141,8 +140,7 @@ public class ExcelUtil<T>
* @param is 输入流 * @param is 输入流
* @return 转换后集合 * @return 转换后集合
*/ */
public List<T> importExcel(InputStream is) throws Exception public List<T> importExcel(InputStream is) throws Exception {
{
return importExcel(StringUtils.EMPTY, is); return importExcel(StringUtils.EMPTY, is);
} }
@ -153,46 +151,36 @@ public class ExcelUtil<T>
* @param is 输入流 * @param is 输入流
* @return 转换后集合 * @return 转换后集合
*/ */
public List<T> importExcel(String sheetName, InputStream is) throws Exception public List<T> importExcel(String sheetName, InputStream is) throws Exception {
{
this.type = Type.IMPORT; this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is); this.wb = WorkbookFactory.create(is);
List<T> list = new ArrayList<T>(); List<T> list = new ArrayList<T>();
Sheet sheet = null; Sheet sheet = null;
if (StringUtils.isNotEmpty(sheetName)) if (StringUtils.isNotEmpty(sheetName)) {
{
// 如果指定sheet名,则取指定sheet中的内容. // 如果指定sheet名,则取指定sheet中的内容.
sheet = wb.getSheet(sheetName); sheet = wb.getSheet(sheetName);
} } else {
else
{
// 如果传入的sheet名不存在则默认指向第1个sheet. // 如果传入的sheet名不存在则默认指向第1个sheet.
sheet = wb.getSheetAt(0); sheet = wb.getSheetAt(0);
} }
if (sheet == null) if (sheet == null) {
{
throw new IOException("文件sheet不存在"); throw new IOException("文件sheet不存在");
} }
int rows = sheet.getPhysicalNumberOfRows(); int rows = sheet.getPhysicalNumberOfRows();
if (rows > 0) if (rows > 0) {
{
// 定义一个map用于存放excel列的序号和field. // 定义一个map用于存放excel列的序号和field.
Map<String, Integer> cellMap = new HashMap<String, Integer>(); Map<String, Integer> cellMap = new HashMap<String, Integer>();
// 获取表头 // 获取表头
Row heard = sheet.getRow(0); Row heard = sheet.getRow(0);
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) {
{
Cell cell = heard.getCell(i); Cell cell = heard.getCell(i);
if (StringUtils.isNotNull(cell)) if (StringUtils.isNotNull(cell)) {
{
String value = this.getCellValue(heard, i).toString(); String value = this.getCellValue(heard, i).toString();
cellMap.put(value, i); cellMap.put(value, i);
} } else {
else
{
cellMap.put(null, i); cellMap.put(null, i);
} }
} }
@ -200,28 +188,23 @@ public class ExcelUtil<T>
Field[] allFields = clazz.getDeclaredFields(); Field[] allFields = clazz.getDeclaredFields();
// 定义一个map用于存放列的序号和field. // 定义一个map用于存放列的序号和field.
Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>(); Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
for (int col = 0; col < allFields.length; col++) for (int col = 0; col < allFields.length; col++) {
{
Field field = allFields[col]; Field field = allFields[col];
Excel attr = field.getAnnotation(Excel.class); Excel attr = field.getAnnotation(Excel.class);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
{
// 设置类的私有字段属性可访问. // 设置类的私有字段属性可访问.
field.setAccessible(true); field.setAccessible(true);
Integer column = cellMap.get(attr.name()); Integer column = cellMap.get(attr.name());
if (column != null) if (column != null) {
{
fieldsMap.put(column, field); fieldsMap.put(column, field);
} }
} }
} }
for (int i = 1; i < rows; i++) for (int i = 1; i < rows; i++) {
{
// 从第2行开始取数据,默认第一行是表头. // 从第2行开始取数据,默认第一行是表头.
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
T entity = null; T entity = null;
for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet()) for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet()) {
{
Object val = this.getCellValue(row, entry.getKey()); Object val = this.getCellValue(row, entry.getKey());
// 如果不存在实例则新建. // 如果不存在实例则新建.
@ -230,67 +213,40 @@ public class ExcelUtil<T>
Field field = fieldsMap.get(entry.getKey()); Field field = fieldsMap.get(entry.getKey());
// 取得类型,并根据对象类型设置值. // 取得类型,并根据对象类型设置值.
Class<?> fieldType = field.getType(); Class<?> fieldType = field.getType();
if (String.class == fieldType) if (String.class == fieldType) {
{
String s = Convert.toStr(val); String s = Convert.toStr(val);
if (StringUtils.endsWith(s, ".0")) if (StringUtils.endsWith(s, ".0")) {
{
val = StringUtils.substringBefore(s, ".0"); val = StringUtils.substringBefore(s, ".0");
} } else {
else
{
val = Convert.toStr(val); val = Convert.toStr(val);
} }
} } else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) {
else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
{
val = Convert.toInt(val); val = Convert.toInt(val);
} } else if (Long.TYPE == fieldType || Long.class == fieldType) {
else if (Long.TYPE == fieldType || Long.class == fieldType)
{
val = Convert.toLong(val); val = Convert.toLong(val);
} } else if (Double.TYPE == fieldType || Double.class == fieldType) {
else if (Double.TYPE == fieldType || Double.class == fieldType)
{
val = Convert.toDouble(val); val = Convert.toDouble(val);
} } else if (Float.TYPE == fieldType || Float.class == fieldType) {
else if (Float.TYPE == fieldType || Float.class == fieldType)
{
val = Convert.toFloat(val); val = Convert.toFloat(val);
} } else if (BigDecimal.class == fieldType) {
else if (BigDecimal.class == fieldType)
{
val = Convert.toBigDecimal(val); val = Convert.toBigDecimal(val);
} } else if (Date.class == fieldType) {
else if (Date.class == fieldType) if (val instanceof String) {
{
if (val instanceof String)
{
val = DateUtils.parseDate(val); val = DateUtils.parseDate(val);
} } else if (val instanceof Double) {
else if (val instanceof Double)
{
val = DateUtil.getJavaDate((Double) val); val = DateUtil.getJavaDate((Double) val);
} }
} } else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) {
else if (Boolean.TYPE == fieldType || Boolean.class == fieldType)
{
val = Convert.toBool(val, false); val = Convert.toBool(val, false);
} }
if (StringUtils.isNotNull(fieldType)) if (StringUtils.isNotNull(fieldType)) {
{
Excel attr = field.getAnnotation(Excel.class); Excel attr = field.getAnnotation(Excel.class);
String propertyName = field.getName(); String propertyName = field.getName();
if (StringUtils.isNotEmpty(attr.targetAttr())) if (StringUtils.isNotEmpty(attr.targetAttr())) {
{
propertyName = field.getName() + "." + attr.targetAttr(); propertyName = field.getName() + "." + attr.targetAttr();
} } else if (StringUtils.isNotEmpty(attr.readConverterExp())) {
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
{
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
} } else if (StringUtils.isNotEmpty(attr.dictType())) {
else if (StringUtils.isNotEmpty(attr.dictType()))
{
val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
} }
ReflectUtils.invokeSetter(entity, propertyName, val); ReflectUtils.invokeSetter(entity, propertyName, val);
@ -309,8 +265,7 @@ public class ExcelUtil<T>
* @param sheetName 工作表的名称 * @param sheetName 工作表的名称
* @return 结果 * @return 结果
*/ */
public AjaxResult exportExcel(List<T> list, String sheetName) public AjaxResult exportExcel(List<T> list, String sheetName) {
{
this.init(list, sheetName, Type.EXPORT); this.init(list, sheetName, Type.EXPORT);
return exportExcel(); return exportExcel();
} }
@ -321,8 +276,7 @@ public class ExcelUtil<T>
* @param sheetName 工作表的名称 * @param sheetName 工作表的名称
* @return 结果 * @return 结果
*/ */
public AjaxResult importTemplateExcel(String sheetName) public AjaxResult importTemplateExcel(String sheetName) {
{
this.init(null, sheetName, Type.IMPORT); this.init(null, sheetName, Type.IMPORT);
return exportExcel(); return exportExcel();
} }
@ -332,28 +286,24 @@ public class ExcelUtil<T>
* *
* @return 结果 * @return 结果
*/ */
public AjaxResult exportExcel() public AjaxResult exportExcel() {
{
OutputStream out = null; OutputStream out = null;
try File file = null;
{ try {
// 取出一共有多少个sheet. // 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize); double sheetNo = Math.ceil(list.size() / sheetSize);
for (int index = 0; index <= sheetNo; index++) for (int index = 0; index <= sheetNo; index++) {
{
createSheet(sheetNo, index); createSheet(sheetNo, index);
// 产生一行 // 产生一行
Row row = sheet.createRow(0); Row row = sheet.createRow(0);
int column = 0; int column = 0;
// 写入各个字段的列头名称 // 写入各个字段的列头名称
for (Object[] os : fields) for (Object[] os : fields) {
{
Excel excel = (Excel) os[1]; Excel excel = (Excel) os[1];
this.createCell(excel, row, column++); this.createCell(excel, row, column++);
} }
if (Type.EXPORT.equals(type)) if (Type.EXPORT.equals(type)) {
{
fillExcelData(index, row); fillExcelData(index, row);
addStatisticsRow(); addStatisticsRow();
} }
@ -361,37 +311,32 @@ public class ExcelUtil<T>
String filename = encodingFilename(sheetName); String filename = encodingFilename(sheetName);
out = new FileOutputStream(getAbsoluteFile(filename)); out = new FileOutputStream(getAbsoluteFile(filename));
wb.write(out); wb.write(out);
return AjaxResult.success(filename); log.info("导出Excel临时路径:{}", getAbsoluteFile(filename));
} file = new File(getAbsoluteFile(filename));
catch (Exception e) String fileKey = cosUtils.uploadFile("export/excel", filename, file);
{ return AjaxResult.success(fileKey);
} catch (Exception e) {
log.error("导出Excel异常{}", e.getMessage()); log.error("导出Excel异常{}", e.getMessage());
throw new CustomException("导出Excel失败请联系网站管理员"); throw new CustomException("导出Excel失败请联系网站管理员");
} } finally {
finally if (wb != null) {
{ try {
if (wb != null)
{
try
{
wb.close(); wb.close();
} } catch (IOException e1) {
catch (IOException e1)
{
e1.printStackTrace(); e1.printStackTrace();
} }
} }
if (out != null) if (out != null) {
{ try {
try
{
out.close(); out.close();
} } catch (IOException e1) {
catch (IOException e1)
{
e1.printStackTrace(); e1.printStackTrace();
} }
} }
if (file != null) {
file.delete();
}
} }
} }
@ -401,18 +346,15 @@ public class ExcelUtil<T>
* @param index 序号 * @param index 序号
* @param row 单元格行 * @param row 单元格行
*/ */
public void fillExcelData(int index, Row row) public void fillExcelData(int index, Row row) {
{
int startNo = index * sheetSize; int startNo = index * sheetSize;
int endNo = Math.min(startNo + sheetSize, list.size()); int endNo = Math.min(startNo + sheetSize, list.size());
for (int i = startNo; i < endNo; i++) for (int i = startNo; i < endNo; i++) {
{
row = sheet.createRow(i + 1 - startNo); row = sheet.createRow(i + 1 - startNo);
// 得到导出对象. // 得到导出对象.
T vo = (T) list.get(i); T vo = (T) list.get(i);
int column = 0; int column = 0;
for (Object[] os : fields) for (Object[] os : fields) {
{
Field field = (Field) os[0]; Field field = (Field) os[0];
Excel excel = (Excel) os[1]; Excel excel = (Excel) os[1];
// 设置实体类私有属性可访问 // 设置实体类私有属性可访问
@ -428,8 +370,7 @@ public class ExcelUtil<T>
* @param wb 工作薄对象 * @param wb 工作薄对象
* @return 样式列表 * @return 样式列表
*/ */
private Map<String, CellStyle> createStyles(Workbook wb) private Map<String, CellStyle> createStyles(Workbook wb) {
{
// 写入各条记录,每条记录对应excel表中的一行 // 写入各条记录,每条记录对应excel表中的一行
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style = wb.createCellStyle(); CellStyle style = wb.createCellStyle();
@ -493,8 +434,7 @@ public class ExcelUtil<T>
/** /**
* 创建单元格 * 创建单元格
*/ */
public Cell createCell(Excel attr, Row row, int column) public Cell createCell(Excel attr, Row row, int column) {
{
// 创建列 // 创建列
Cell cell = row.createCell(column); Cell cell = row.createCell(column);
// 写入列信息 // 写入列信息
@ -511,14 +451,10 @@ public class ExcelUtil<T>
* @param attr 注解相关 * @param attr 注解相关
* @param cell 单元格信息 * @param cell 单元格信息
*/ */
public void setCellVo(Object value, Excel attr, Cell cell) public void setCellVo(Object value, Excel attr, Cell cell) {
{ if (ColumnType.STRING == attr.cellType()) {
if (ColumnType.STRING == attr.cellType())
{
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
} } else if (ColumnType.NUMERIC == attr.cellType()) {
else if (ColumnType.NUMERIC == attr.cellType())
{
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value)); cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
} }
} }
@ -526,27 +462,21 @@ public class ExcelUtil<T>
/** /**
* 创建表格样式 * 创建表格样式
*/ */
public void setDataValidation(Excel attr, Row row, int column) public void setDataValidation(Excel attr, Row row, int column) {
{ if (attr.name().indexOf("注:") >= 0) {
if (attr.name().indexOf("注:") >= 0)
{
sheet.setColumnWidth(column, 6000); sheet.setColumnWidth(column, 6000);
} } else {
else
{
// 设置列宽 // 设置列宽
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
row.setHeight((short) (attr.height() * 20)); row.setHeight((short) (attr.height() * 20));
} }
// 如果设置了提示信息则鼠标放上去提示. // 如果设置了提示信息则鼠标放上去提示.
if (StringUtils.isNotEmpty(attr.prompt())) if (StringUtils.isNotEmpty(attr.prompt())) {
{
// 这里默认设了2-101列提示. // 这里默认设了2-101列提示.
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
} }
// 如果设置了combo属性则本列只能选择不能输入 // 如果设置了combo属性则本列只能选择不能输入
if (attr.combo().length > 0) if (attr.combo().length > 0) {
{
// 这里默认设了2-101列只能选择不能输入. // 这里默认设了2-101列只能选择不能输入.
setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
} }
@ -555,16 +485,13 @@ public class ExcelUtil<T>
/** /**
* 添加单元格 * 添加单元格
*/ */
public Cell addCell(Excel attr, Row row, T vo, Field field, int column) public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
{
Cell cell = null; Cell cell = null;
try try {
{
// 设置行高 // 设置行高
row.setHeight((short) (attr.height() * 20)); row.setHeight((short) (attr.height() * 20));
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
if (attr.isExport()) if (attr.isExport()) {
{
// 创建cell // 创建cell
cell = row.createCell(column); cell = row.createCell(column);
int align = attr.align().value(); int align = attr.align().value();
@ -576,32 +503,21 @@ public class ExcelUtil<T>
String readConverterExp = attr.readConverterExp(); String readConverterExp = attr.readConverterExp();
String separator = attr.separator(); String separator = attr.separator();
String dictType = attr.dictType(); String dictType = attr.dictType();
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) {
{
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
} } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) {
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
{
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
} } else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) {
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
{
cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
} } else if (value instanceof BigDecimal && -1 != attr.scale()) {
else if (value instanceof BigDecimal && -1 != attr.scale())
{
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString()); cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
} } else {
else
{
// 设置列类型 // 设置列类型
setCellVo(value, attr, cell); setCellVo(value, attr, cell);
} }
addStatisticsData(column, Convert.toStr(value), attr); addStatisticsData(column, Convert.toStr(value), attr);
} }
} } catch (Exception e) {
catch (Exception e)
{
log.error("导出Excel失败{}", e); log.error("导出Excel失败{}", e);
} }
return cell; return cell;
@ -619,8 +535,7 @@ public class ExcelUtil<T>
* @param endCol 结束列 * @param endCol 结束列
*/ */
public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
int firstCol, int endCol) int firstCol, int endCol) {
{
DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationHelper helper = sheet.getDataValidationHelper();
DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
@ -641,8 +556,7 @@ public class ExcelUtil<T>
* @param endCol 结束列 * @param endCol 结束列
* @return 设置好的sheet. * @return 设置好的sheet.
*/ */
public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) {
{
DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationHelper helper = sheet.getDataValidationHelper();
// 加载下拉列表内容 // 加载下拉列表内容
DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
@ -651,13 +565,10 @@ public class ExcelUtil<T>
// 数据有效性对象 // 数据有效性对象
DataValidation dataValidation = helper.createValidation(constraint, regions); DataValidation dataValidation = helper.createValidation(constraint, regions);
// 处理Excel兼容性问题 // 处理Excel兼容性问题
if (dataValidation instanceof XSSFDataValidation) if (dataValidation instanceof XSSFDataValidation) {
{
dataValidation.setSuppressDropDownArrow(true); dataValidation.setSuppressDropDownArrow(true);
dataValidation.setShowErrorBox(true); dataValidation.setShowErrorBox(true);
} } else {
else
{
dataValidation.setSuppressDropDownArrow(false); dataValidation.setSuppressDropDownArrow(false);
} }
@ -672,28 +583,20 @@ public class ExcelUtil<T>
* @param separator 分隔符 * @param separator 分隔符
* @return 解析后值 * @return 解析后值
*/ */
public static String convertByExp(String propertyValue, String converterExp, String separator) public static String convertByExp(String propertyValue, String converterExp, String separator) {
{
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(","); String[] convertSource = converterExp.split(",");
for (String item : convertSource) for (String item : convertSource) {
{
String[] itemArray = item.split("="); String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) if (StringUtils.containsAny(separator, propertyValue)) {
{ for (String value : propertyValue.split(separator)) {
for (String value : propertyValue.split(separator)) if (itemArray[0].equals(value)) {
{
if (itemArray[0].equals(value))
{
propertyString.append(itemArray[1] + separator); propertyString.append(itemArray[1] + separator);
break; break;
} }
} }
} } else {
else if (itemArray[0].equals(propertyValue)) {
{
if (itemArray[0].equals(propertyValue))
{
return itemArray[1]; return itemArray[1];
} }
} }
@ -709,28 +612,20 @@ public class ExcelUtil<T>
* @param separator 分隔符 * @param separator 分隔符
* @return 解析后值 * @return 解析后值
*/ */
public static String reverseByExp(String propertyValue, String converterExp, String separator) public static String reverseByExp(String propertyValue, String converterExp, String separator) {
{
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(","); String[] convertSource = converterExp.split(",");
for (String item : convertSource) for (String item : convertSource) {
{
String[] itemArray = item.split("="); String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) if (StringUtils.containsAny(separator, propertyValue)) {
{ for (String value : propertyValue.split(separator)) {
for (String value : propertyValue.split(separator)) if (itemArray[1].equals(value)) {
{
if (itemArray[1].equals(value))
{
propertyString.append(itemArray[0] + separator); propertyString.append(itemArray[0] + separator);
break; break;
} }
} }
} } else {
else if (itemArray[1].equals(propertyValue)) {
{
if (itemArray[1].equals(propertyValue))
{
return itemArray[0]; return itemArray[0];
} }
} }
@ -746,8 +641,7 @@ public class ExcelUtil<T>
* @param separator 分隔符 * @param separator 分隔符
* @return 字典标签 * @return 字典标签
*/ */
public static String convertDictByExp(String dictValue, String dictType, String separator) public static String convertDictByExp(String dictValue, String dictType, String separator) {
{
return DictUtils.getDictLabel(dictType, dictValue, separator); return DictUtils.getDictLabel(dictType, dictValue, separator);
} }
@ -759,29 +653,22 @@ public class ExcelUtil<T>
* @param separator 分隔符 * @param separator 分隔符
* @return 字典值 * @return 字典值
*/ */
public static String reverseDictByExp(String dictLabel, String dictType, String separator) public static String reverseDictByExp(String dictLabel, String dictType, String separator) {
{
return DictUtils.getDictValue(dictType, dictLabel, separator); return DictUtils.getDictValue(dictType, dictLabel, separator);
} }
/** /**
* 合计统计信息 * 合计统计信息
*/ */
private void addStatisticsData(Integer index, String text, Excel entity) private void addStatisticsData(Integer index, String text, Excel entity) {
{ if (entity != null && entity.isStatistics()) {
if (entity != null && entity.isStatistics())
{
Double temp = 0D; Double temp = 0D;
if (!statistics.containsKey(index)) if (!statistics.containsKey(index)) {
{
statistics.put(index, temp); statistics.put(index, temp);
} }
try try {
{
temp = Double.valueOf(text); temp = Double.valueOf(text);
} } catch (NumberFormatException e) {
catch (NumberFormatException e)
{
} }
statistics.put(index, statistics.get(index) + temp); statistics.put(index, statistics.get(index) + temp);
} }
@ -790,10 +677,8 @@ public class ExcelUtil<T>
/** /**
* 创建统计行 * 创建统计行
*/ */
public void addStatisticsRow() public void addStatisticsRow() {
{ if (statistics.size() > 0) {
if (statistics.size() > 0)
{
Cell cell = null; Cell cell = null;
Row row = sheet.createRow(sheet.getLastRowNum() + 1); Row row = sheet.createRow(sheet.getLastRowNum() + 1);
Set<Integer> keys = statistics.keySet(); Set<Integer> keys = statistics.keySet();
@ -801,8 +686,7 @@ public class ExcelUtil<T>
cell.setCellStyle(styles.get("total")); cell.setCellStyle(styles.get("total"));
cell.setCellValue("合计"); cell.setCellValue("合计");
for (Integer key : keys) for (Integer key : keys) {
{
cell = row.createCell(key); cell = row.createCell(key);
cell.setCellStyle(styles.get("total")); cell.setCellStyle(styles.get("total"));
cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key))); cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
@ -814,8 +698,7 @@ public class ExcelUtil<T>
/** /**
* 编码文件名 * 编码文件名
*/ */
public String encodingFilename(String filename) public String encodingFilename(String filename) {
{
filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
return filename; return filename;
} }
@ -825,12 +708,10 @@ public class ExcelUtil<T>
* *
* @param filename 文件名称 * @param filename 文件名称
*/ */
public String getAbsoluteFile(String filename) public String getAbsoluteFile(String filename) {
{
String downloadPath = RuoYiConfig.getDownloadPath() + filename; String downloadPath = RuoYiConfig.getDownloadPath() + filename;
File desc = new File(downloadPath); File desc = new File(downloadPath);
if (!desc.getParentFile().exists()) if (!desc.getParentFile().exists()) {
{
desc.getParentFile().mkdirs(); desc.getParentFile().mkdirs();
} }
return downloadPath; return downloadPath;
@ -845,22 +726,16 @@ public class ExcelUtil<T>
* @return 最终的属性值 * @return 最终的属性值
* @throws Exception * @throws Exception
*/ */
private Object getTargetValue(T vo, Field field, Excel excel) throws Exception private Object getTargetValue(T vo, Field field, Excel excel) throws Exception {
{
Object o = field.get(vo); Object o = field.get(vo);
if (StringUtils.isNotEmpty(excel.targetAttr())) if (StringUtils.isNotEmpty(excel.targetAttr())) {
{
String target = excel.targetAttr(); String target = excel.targetAttr();
if (target.indexOf(".") > -1) if (target.indexOf(".") > -1) {
{
String[] targets = target.split("[.]"); String[] targets = target.split("[.]");
for (String name : targets) for (String name : targets) {
{
o = getValue(o, name); o = getValue(o, name);
} }
} } else {
else
{
o = getValue(o, target); o = getValue(o, target);
} }
} }
@ -875,10 +750,8 @@ public class ExcelUtil<T>
* @return value * @return value
* @throws Exception * @throws Exception
*/ */
private Object getValue(Object o, String name) throws Exception private Object getValue(Object o, String name) throws Exception {
{ if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) {
if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name))
{
Class<?> clazz = o.getClass(); Class<?> clazz = o.getClass();
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
@ -890,27 +763,22 @@ public class ExcelUtil<T>
/** /**
* 得到所有定义字段 * 得到所有定义字段
*/ */
private void createExcelField() private void createExcelField() {
{
this.fields = new ArrayList<Object[]>(); this.fields = new ArrayList<Object[]>();
List<Field> tempFields = new ArrayList<>(); List<Field> tempFields = new ArrayList<>();
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
for (Field field : tempFields) for (Field field : tempFields) {
{
// 单注解 // 单注解
if (field.isAnnotationPresent(Excel.class)) if (field.isAnnotationPresent(Excel.class)) {
{
putToField(field, field.getAnnotation(Excel.class)); putToField(field, field.getAnnotation(Excel.class));
} }
// 多注解 // 多注解
if (field.isAnnotationPresent(Excels.class)) if (field.isAnnotationPresent(Excels.class)) {
{
Excels attrs = field.getAnnotation(Excels.class); Excels attrs = field.getAnnotation(Excels.class);
Excel[] excels = attrs.value(); Excel[] excels = attrs.value();
for (Excel excel : excels) for (Excel excel : excels) {
{
putToField(field, excel); putToField(field, excel);
} }
} }
@ -921,10 +789,8 @@ public class ExcelUtil<T>
/** /**
* 放到字段集合中 * 放到字段集合中
*/ */
private void putToField(Field field, Excel attr) private void putToField(Field field, Excel attr) {
{ if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
{
this.fields.add(new Object[]{field, attr}); this.fields.add(new Object[]{field, attr});
} }
} }
@ -932,8 +798,7 @@ public class ExcelUtil<T>
/** /**
* 创建一个工作簿 * 创建一个工作簿
*/ */
public void createWorkbook() public void createWorkbook() {
{
this.wb = new SXSSFWorkbook(500); this.wb = new SXSSFWorkbook(500);
} }
@ -943,17 +808,13 @@ public class ExcelUtil<T>
* @param sheetNo sheet数量 * @param sheetNo sheet数量
* @param index 序号 * @param index 序号
*/ */
public void createSheet(double sheetNo, int index) public void createSheet(double sheetNo, int index) {
{
this.sheet = wb.createSheet(); this.sheet = wb.createSheet();
this.styles = createStyles(wb); this.styles = createStyles(wb);
// 设置工作表的名称. // 设置工作表的名称.
if (sheetNo == 0) if (sheetNo == 0) {
{
wb.setSheetName(index, sheetName); wb.setSheetName(index, sheetName);
} } else {
else
{
wb.setSheetName(index, sheetName + index); wb.setSheetName(index, sheetName + index);
} }
} }
@ -965,54 +826,35 @@ public class ExcelUtil<T>
* @param column 获取单元格列号 * @param column 获取单元格列号
* @return 单元格值 * @return 单元格值
*/ */
public Object getCellValue(Row row, int column) public Object getCellValue(Row row, int column) {
{ if (row == null) {
if (row == null)
{
return row; return row;
} }
Object val = ""; Object val = "";
try try {
{
Cell cell = row.getCell(column); Cell cell = row.getCell(column);
if (StringUtils.isNotNull(cell)) if (StringUtils.isNotNull(cell)) {
{ if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) {
if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA)
{
val = cell.getNumericCellValue(); val = cell.getNumericCellValue();
if (DateUtil.isCellDateFormatted(cell)) if (DateUtil.isCellDateFormatted(cell)) {
{
val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
} } else {
else if ((Double) val % 1 > 0) {
{
if ((Double) val % 1 > 0)
{
val = new BigDecimal(val.toString()); val = new BigDecimal(val.toString());
} } else {
else
{
val = new DecimalFormat("0").format(val); val = new DecimalFormat("0").format(val);
} }
} }
} } else if (cell.getCellType() == CellType.STRING) {
else if (cell.getCellType() == CellType.STRING)
{
val = cell.getStringCellValue(); val = cell.getStringCellValue();
} } else if (cell.getCellType() == CellType.BOOLEAN) {
else if (cell.getCellType() == CellType.BOOLEAN)
{
val = cell.getBooleanCellValue(); val = cell.getBooleanCellValue();
} } else if (cell.getCellType() == CellType.ERROR) {
else if (cell.getCellType() == CellType.ERROR)
{
val = cell.getErrorCellValue(); val = cell.getErrorCellValue();
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
return val; return val;
} }
return val; return val;

View File

@ -1,15 +1,15 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="部门ID" prop="deptId"> <!-- <el-form-item label="部门ID" prop="deptId">-->
<el-input <!-- <el-input-->
v-model="queryParams.deptId" <!-- v-model="queryParams.deptId"-->
placeholder="请输入部门ID" <!-- placeholder="请输入部门ID"-->
clearable <!-- clearable-->
size="small" <!-- size="small"-->
@keyup.enter.native="handleQuery" <!-- @keyup.enter.native="handleQuery"-->
/> <!-- />-->
</el-form-item> <!-- </el-form-item>-->
<el-form-item label="新闻标题" prop="newsTitle"> <el-form-item label="新闻标题" prop="newsTitle">
<el-input <el-input
v-model="queryParams.newsTitle" v-model="queryParams.newsTitle"
@ -87,33 +87,33 @@
>删除 >删除
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="warning" <!-- type="warning"-->
icon="el-icon-download" <!-- icon="el-icon-download"-->
size="mini" <!-- size="mini"-->
@click="handleExport" <!-- @click="handleExport"-->
v-hasPermi="['news:news_content:export']" <!-- v-hasPermi="['news:news_content:export']"-->
>导出 <!-- >导出-->
</el-button> <!-- </el-button>-->
</el-col> <!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="news_contentList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="news_contentList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="规格ID" align="center" prop="id" v-if="false"/> <el-table-column label="规格ID" align="center" prop="id" v-if="false"/>
<el-table-column label="部门ID" align="center" prop="deptId"/> <!-- <el-table-column label="部门ID" align="center" prop="deptId"/>-->
<el-table-column label="新闻标题" align="center" prop="newsTitle"/> <el-table-column label="新闻标题" align="center" prop="newsTitle"/>
<!-- <el-table-column label="新闻详情" align="center" prop="newsBody"/>--> <!-- <el-table-column label="新闻详情" align="center" prop="newsBody"/>-->
<el-table-column label="新闻封面图" align="center" prop="newsImage"> <el-table-column label="新闻封面图" align="center" prop="newsImage" width="100px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-image :src="scope.row.newsImage|getImageForKey" style="width: 60px; height: 60px"/> <el-image :src="scope.row.newsImage|getImageForKey" style="width: 60px; height: 60px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="新闻类型" align="center" prop="newsType" :formatter="newsTypeFormat"/> <el-table-column label="新闻类型" align="center" prop="newsType" :formatter="newsTypeFormat"/>
<el-table-column label="状态" align="center" prop="state" :formatter="stateFormat"> <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat" width="100px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.state === 1 ? 'success' : 'danger'"> <el-tag :type="scope.row.state === 1 ? 'success' : 'danger'">
{{scope.row.state | getStateName(stateOptions)}} {{scope.row.state | getStateName(stateOptions)}}
@ -151,8 +151,8 @@
/> />
<!-- 添加或修改新闻资讯对话框 --> <!-- 添加或修改新闻资讯对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<!-- <el-form-item label="部门ID" prop="deptId">--> <!-- <el-form-item label="部门ID" prop="deptId">-->
<!-- <el-input v-model="form.deptId" placeholder="请输入部门ID"/>--> <!-- <el-input v-model="form.deptId" placeholder="请输入部门ID"/>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
@ -195,9 +195,10 @@
</el-form-item> </el-form-item>
<el-form-item label="新闻详情" prop="newsBody"> <el-form-item label="新闻详情" prop="newsBody">
<editor :value="form.newsBody" :height="400" :min-height="400" @on-change="onChangeNewsBody"/>
<!-- <el-input v-model="form.newsBody" placeholder="请输入新闻详情" />--> <!-- <el-input v-model="form.newsBody" placeholder="请输入新闻详情" />-->
<editor :value="form.newsBody" :height="400" :min-height="400" @on-change="onChangeNewsBody"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>