|
@@ -5,7 +5,6 @@ import com.caimei.mapper.cmMapper.AuthMapper;
|
|
|
import com.caimei.mapper.cmMapper.AuthProductMapper;
|
|
|
import com.caimei.mapper.ldmMapper.LdmMapper;
|
|
|
import com.caimei.model.ResponseJson;
|
|
|
-import com.caimei.model.dto.ProductSaveDto;
|
|
|
import com.caimei.model.po.*;
|
|
|
import com.caimei.model.vo.*;
|
|
|
import com.caimei.service.auth.AuthProductService;
|
|
@@ -13,38 +12,32 @@ import com.caimei.service.auth.AuthService;
|
|
|
import com.caimei.service.auth.ShopService;
|
|
|
import com.caimei.service.auth.UploadService;
|
|
|
import com.caimei.utils.Base64Util;
|
|
|
-import com.caimei.utils.ExcelOperateUtil;
|
|
|
import com.caimei.utils.ImageUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.swing.*;
|
|
|
import java.awt.*;
|
|
|
import java.awt.Font;
|
|
|
-import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -65,9 +58,6 @@ public class AuthServiceImpl implements AuthService {
|
|
|
@Value("${caimei.zpapi}")
|
|
|
private String zpServer;
|
|
|
|
|
|
- @Resource
|
|
|
- private AuthProductMapper authProductMapper;
|
|
|
-
|
|
|
private AuthProductService authProductService;
|
|
|
|
|
|
@Autowired
|
|
@@ -100,15 +90,11 @@ public class AuthServiceImpl implements AuthService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
|
|
|
- String mobile, Integer status, Integer auditStatus, Integer lowerAuditStatus,
|
|
|
- Integer shopAuditStatus, Integer sendStatus,
|
|
|
- Integer pageNum, Integer pageSize) {
|
|
|
- if (null == authUserId) {
|
|
|
- return ResponseJson.error("参数异常,请输入供应商用户id", null);
|
|
|
- }
|
|
|
+ String mobile, Integer status, Integer starFlag, Integer auditStatus,
|
|
|
+ Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize) {
|
|
|
listType = null == listType ? 1 : listType;
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus);
|
|
|
+ List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus);
|
|
|
PageInfo<AuthVo> pageData = new PageInfo<>(authList);
|
|
|
return ResponseJson.success(pageData);
|
|
|
}
|
|
@@ -164,7 +150,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
|
|
|
- List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null);
|
|
|
+ List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null, null);
|
|
|
return ResponseJson.success(authList);
|
|
|
}
|
|
|
|
|
@@ -199,6 +185,18 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseJson checkAuth(Integer authId) {
|
|
|
+ authMapper.checkAuth(authId);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson starAuth(Integer authId, Integer starFlag) {
|
|
|
+ authMapper.starAuth(authId, starFlag);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
private void insertBanner(String pic, Integer authId) {
|
|
|
if (StringUtils.isNotEmpty(pic)) {
|
|
|
String imagePath = "https://wangdian.skinovachina.com" + pic;
|
|
@@ -215,18 +213,15 @@ public class AuthServiceImpl implements AuthService {
|
|
|
@Override
|
|
|
public ResponseJson saveAuth(CmBrandAuthPo auth, List<String> bannerList, boolean importFlag, Integer source) {
|
|
|
Integer authId = auth.getId();
|
|
|
- Integer authUserId = auth.getAuthUserId();
|
|
|
- String authParty = auth.getAuthParty();
|
|
|
- if (null == authUserId) {
|
|
|
- return ResponseJson.error("参数异常,请输入供应商用户id");
|
|
|
+ boolean insertFlag = null == authId;
|
|
|
+ AuthVo dbAuth = null;
|
|
|
+ if (!insertFlag) {
|
|
|
+ dbAuth = authMapper.getAuthById(authId);
|
|
|
}
|
|
|
+ String authParty = auth.getAuthParty();
|
|
|
if (StringUtils.isBlank(authParty)) {
|
|
|
return ResponseJson.error("参数异常,请输入授权机构名称");
|
|
|
}
|
|
|
- /*Integer authIdByAuthParty = authMapper.getAuthIdByAuthParty(authParty, authUserId);
|
|
|
- if (null != authIdByAuthParty && !authIdByAuthParty.equals(authId)) {
|
|
|
- return ResponseJson.error("参数异常,该授权机构已存在,请重新输入");
|
|
|
- }*/
|
|
|
if (null == auth.getFirstClubType()) {
|
|
|
return ResponseJson.error("请勾选机构类型");
|
|
|
}
|
|
@@ -264,21 +259,29 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return ResponseJson.error("参数异常,请上传轮播图");
|
|
|
}
|
|
|
}
|
|
|
- // 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
|
|
|
- /*auth.setStatus(2);
|
|
|
- auth.setAuditStatus(2);*/
|
|
|
// 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
|
|
|
- auth.setStatus(1 == source ? 1 : 2);
|
|
|
- auth.setAuditStatus(1 == source ? 1 : 2);
|
|
|
+ if (null != dbAuth && 1 != dbAuth.getAuditStatus()) {
|
|
|
+ // 被驳回的数据,编辑变为待审核状态
|
|
|
+ auth.setStatus(2);
|
|
|
+ auth.setAuditStatus(2);
|
|
|
+ } else {
|
|
|
+ auth.setStatus(1 == source ? 1 : 2);
|
|
|
+ auth.setAuditStatus(1 == source ? 1 : 2);
|
|
|
+ }
|
|
|
Integer adminUserId = authMapper.getAdminUserId();
|
|
|
auth.setAuditBy(adminUserId);
|
|
|
auth.setAuditTime(new Date());
|
|
|
+ if (1 == source) {
|
|
|
+ auth.setShopAuditBy(auth.getCreateBy());
|
|
|
+ auth.setShopAuditTime(new Date());
|
|
|
+ }
|
|
|
auth.setDelFlag(0);
|
|
|
+ auth.setCheckFlag(0);
|
|
|
auth.setShopAuditStatus(1 == source ? 1 : 2);
|
|
|
/*
|
|
|
保存授权
|
|
|
*/
|
|
|
- if (null == authId) {
|
|
|
+ if (insertFlag) {
|
|
|
authMapper.insertAuth(auth);
|
|
|
} else {
|
|
|
authMapper.updateAuthByAuthId(auth);
|
|
@@ -293,12 +296,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
TemplateVo authTemplate = authMapper.getAuthTemplate(auth.getId(), null, 1);
|
|
|
authImage = generateAuthImage(authTemplate, auth);
|
|
|
auth.setAuthImage(authImage);
|
|
|
- // 添加水印
|
|
|
- if (StringUtils.isNotEmpty(authImage)) {
|
|
|
- auth.setPcAuthImage(addWaterMark(authImage, 1));
|
|
|
- auth.setAppletsAuthImage(addWaterMark(authImage, 2));
|
|
|
- authMapper.updateAuthImage(auth);
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 添加水印
|
|
|
+ if (StringUtils.isNotEmpty(auth.getAuthImage())) {
|
|
|
+ auth.setPcAuthImage(addWaterMark(auth.getAuthImage(), 1));
|
|
|
+ auth.setAppletsAuthImage(addWaterMark(auth.getAuthImage(), 2));
|
|
|
+ authMapper.updateAuthImage(auth);
|
|
|
}
|
|
|
// 保存轮播图
|
|
|
if (null != bannerList) {
|
|
@@ -395,7 +398,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
map.put("addWord1_style", Font.BOLD);
|
|
|
map.put("addWord1_size", (int) Math.round(90 * rate));
|
|
|
map.put("addWord1_x", (int) Math.round(2168 * rate));
|
|
|
- map.put("addWord1_y", (int) Math.round(3165 * rate));
|
|
|
+ map.put("addWord1_y", (int) Math.round(3160 * rate));
|
|
|
}
|
|
|
// 添加认证日期信息
|
|
|
if (null != auth.getAuthDate()) {
|
|
@@ -434,9 +437,6 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (auditStatus == 0 && StringUtils.isEmpty(invalidReason)) {
|
|
|
return ResponseJson.error("请输入审核不通过的原因");
|
|
|
}
|
|
|
- if (auditBy == null) {
|
|
|
- return ResponseJson.error("请输入审核人用户id");
|
|
|
- }
|
|
|
source = null == source ? 1 : source;
|
|
|
Date auditTime = new Date();
|
|
|
// 授权状态更新
|
|
@@ -455,11 +455,12 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (2 == source) {
|
|
|
authMapper.updateAuthShopAuditStatus(authId, status, auditStatus, invalidReason, auditBy, auditTime);
|
|
|
}
|
|
|
- return ResponseJson.success("审核品牌授权成功");
|
|
|
+ return ResponseJson.success("审核机构认证成功");
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor=Exception.class)
|
|
|
public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
String randomStr = UUID.randomUUID().toString();
|
|
@@ -485,42 +486,6 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
|
|
|
- try {
|
|
|
- // 导出表格名
|
|
|
- String fileName = new String("机构商品数据.xls".getBytes("UTF-8"),"iso-8859-1");
|
|
|
- // 机构数据
|
|
|
- List<CmBrandAuthPo> authPartyList = authMapper.getAuthPartyList(authUserId);
|
|
|
- authPartyList.forEach(authParty->{
|
|
|
- // 商品参数数量最大值
|
|
|
- final Integer[] maxParamNum = {0};
|
|
|
- Integer authId = authParty.getId();
|
|
|
- List<ProductFormVo> productList = authProductMapper.getAuthProductList(authId);
|
|
|
- productList.forEach(product->{
|
|
|
- // 参数列表
|
|
|
- List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(product.getProductId());
|
|
|
- product.setParamList(paramList);
|
|
|
- if (paramList.size() > maxParamNum[0]) {
|
|
|
- maxParamNum[0] = paramList.size();
|
|
|
- }
|
|
|
- });
|
|
|
- authParty.setMaxParamNum(maxParamNum[0]);
|
|
|
- authParty.setProductList(productList);
|
|
|
- });
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
- response.reset();
|
|
|
- response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
- response.setHeader("Access-Control-Allow-Credentials", "true");
|
|
|
- response.setHeader("Content-disposition",
|
|
|
- "attachment; filename="+fileName);
|
|
|
- response.setContentType("application/vnd.ms-excel");
|
|
|
- return exportData(authPartyList, outputStream);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return ResponseJson.error("导出失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private ResponseJson saveExcelData(String filePath, Integer authUserId, Integer createBy) {
|
|
|
//判断是否为excel类型文件
|
|
@@ -531,182 +496,173 @@ public class AuthServiceImpl implements AuthService {
|
|
|
List<String> shopBrands = shopService.getShopBrands(authUserId);
|
|
|
|
|
|
// 授权列表
|
|
|
- List<AuthImportPo> authImportList = new ArrayList<>();
|
|
|
-
|
|
|
- List<String> tempImageList = new ArrayList<>();
|
|
|
+ List<CmBrandAuthPo> authImportList = new ArrayList<>();
|
|
|
|
|
|
try {
|
|
|
FileInputStream fis = new FileInputStream(filePath);
|
|
|
// 得到表格数据
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(fis);
|
|
|
- // 获取工作表数量
|
|
|
- int sheetsNum = workbook.getNumberOfSheets();
|
|
|
|
|
|
//得到第一个工作表(机构表)
|
|
|
XSSFSheet authPartySheet = workbook.getSheetAt(0);
|
|
|
//获得表头
|
|
|
Row rowHead = authPartySheet.getRow(0);
|
|
|
//判断表头是否正确
|
|
|
- if (1 != rowHead.getLastCellNum() || !"授权机构".equals(rowHead.getCell(0).getStringCellValue())) {
|
|
|
+ if (9 != rowHead.getLastCellNum() || !"机构名称".equals(rowHead.getCell(0).getStringCellValue())) {
|
|
|
return ResponseJson.error("授权机构表格式错误");
|
|
|
}
|
|
|
// 获得数据的总行数
|
|
|
int authPartyRowNum = authPartySheet.getLastRowNum();
|
|
|
- // 商品sn码列表
|
|
|
- List<String> snCodeList = new ArrayList<>();
|
|
|
|
|
|
//获得所有数据
|
|
|
for (int i = 1; i <= authPartyRowNum; i++) {
|
|
|
//获得第i行对象
|
|
|
- Row row = authPartySheet.getRow(i);
|
|
|
- //获得获得第i行第0列的机构名称
|
|
|
- Cell cell = row.getCell(0);
|
|
|
- // 机构名称
|
|
|
+ Row authPartyRow = authPartySheet.getRow(i);
|
|
|
+ if (null == authPartyRow) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Cell cell = null;
|
|
|
+ // 校验机构名称
|
|
|
+ cell = authPartyRow.getCell(0);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
String authParty = cell.getStringCellValue();
|
|
|
- if (StringUtils.isNotEmpty(authParty)) {
|
|
|
- /*
|
|
|
- * 授权数据
|
|
|
- */
|
|
|
- AuthImportPo authImportPo = new AuthImportPo();
|
|
|
- // 商品列表
|
|
|
- List<ProductSaveDto> productList = new ArrayList<>();
|
|
|
-
|
|
|
- // 得到机构对应的商品工作表
|
|
|
- XSSFSheet productSheet = i < sheetsNum ? workbook.getSheetAt(i) : null;
|
|
|
- String sheetName = null != productSheet ? productSheet.getSheetName() : null;
|
|
|
- if (null == productSheet || !authParty.equals(sheetName)) {
|
|
|
- // 遍历所有工作表,找到表名与授权机构名称相同的商品工作表
|
|
|
- for (int j = 1; j < sheetsNum; j++) {
|
|
|
- productSheet = workbook.getSheetAt(j);
|
|
|
- sheetName = productSheet.getSheetName();
|
|
|
- if (!authParty.equals(sheetName)) {
|
|
|
- // 没有该机构对应的商品表
|
|
|
- productSheet = null;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (StringUtils.isBlank(authParty)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行机构名称不能为空");
|
|
|
+ }
|
|
|
+ // 校验省市区
|
|
|
+ cell = authPartyRow.getCell(1);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String area = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isBlank(area)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行所在地区不能为空");
|
|
|
+ }
|
|
|
+ String[] areaSplit = area.split("/");
|
|
|
+ if (areaSplit.length < 2 || areaSplit.length > 3) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行所在地区格式错误");
|
|
|
+ }
|
|
|
+ // 省份
|
|
|
+ String provinceName = areaSplit[0];
|
|
|
+ if (StringUtils.isBlank(provinceName)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行省份不能为空");
|
|
|
+ }
|
|
|
+ if (provinceName.length() > 2) {
|
|
|
+ provinceName = provinceName.substring(0, provinceName.length() - 1).trim();
|
|
|
+ }
|
|
|
+ Integer provinceId = authMapper.getProvinceId(provinceName);
|
|
|
+ // 市名
|
|
|
+ String cityName = areaSplit[1];
|
|
|
+ if (StringUtils.isBlank(cityName)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行市名不能为空");
|
|
|
+ }
|
|
|
+ if (cityName.length() > 2) {
|
|
|
+ cityName = cityName.substring(0, cityName.length() - 1).trim();
|
|
|
+ }
|
|
|
+ Integer cityId = authMapper.getCityId(cityName);
|
|
|
+ Integer townId = null;
|
|
|
+ if (areaSplit.length > 2) {
|
|
|
+ // 区名
|
|
|
+ String townName = areaSplit[2];
|
|
|
+ if (StringUtils.isNotEmpty(townName) && townName.length() > 2) {
|
|
|
+ townName = townName.substring(0, townName.length() - 1).trim();
|
|
|
}
|
|
|
- if (null != productSheet) {
|
|
|
- //获得表头
|
|
|
- Row productRowHead = productSheet.getRow(0);
|
|
|
- //判断表头是否正确
|
|
|
- short cellTotalNum = productRowHead.getLastCellNum();
|
|
|
- if (cellTotalNum < 13) {
|
|
|
- return ResponseJson.error(authParty + "机构商品表格式错误");
|
|
|
- }
|
|
|
- // 获取表格图片
|
|
|
- Map<String, XSSFPictureData> pictures = ExcelOperateUtil.getPictures(productSheet);
|
|
|
- Map<String, String> imageMap = ExcelOperateUtil.printImg(pictures);
|
|
|
- // 校验商品数据是否符合规范
|
|
|
- int productRowNum = productSheet.getLastRowNum();
|
|
|
- for (int k = 1; k <= productRowNum; k++) {
|
|
|
- XSSFRow productRow = productSheet.getRow(k);
|
|
|
- if (null != productRow && productRow.getCell(0) != null) {
|
|
|
- String errorReason = "";
|
|
|
- // 校验商品名称
|
|
|
- String productName = productRow.getCell(0).getStringCellValue();
|
|
|
- if (StringUtils.isEmpty(productName)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
|
|
|
- }
|
|
|
- // 校验商品sn码
|
|
|
- String snCode = productRow.getCell(1).getStringCellValue();
|
|
|
- if (StringUtils.isEmpty(snCode)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
|
|
|
- } else {
|
|
|
- Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
|
|
|
- if (null != productIdBySnCode || snCodeList.contains(snCode)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品sn码已存在,请重新输入";
|
|
|
- } else {
|
|
|
- snCodeList.add(snCode);
|
|
|
- }
|
|
|
+ List<TownPo> townList = authMapper.getTownList(townName);
|
|
|
+ for (int j = 0; j < townList.size(); j++) {
|
|
|
+ TownPo town = townList.get(j);
|
|
|
+ if (null == townId) {
|
|
|
+ if (null != cityId) {
|
|
|
+ if (town.getCityId().equals(cityId)) {
|
|
|
+ townId = town.getTownId();
|
|
|
}
|
|
|
- // 校验品牌名称
|
|
|
- String brand = productRow.getCell(2).getStringCellValue();
|
|
|
- Integer brandId = null;
|
|
|
- if (StringUtils.isEmpty(brand)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不能为空";
|
|
|
- } else {
|
|
|
- if (!shopBrands.contains(brand)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不存在";
|
|
|
- } else {
|
|
|
- brandId = authProductMapper.getBrandIdByBrandName(brand);
|
|
|
- }
|
|
|
- }
|
|
|
- // 校验商品图片
|
|
|
- String productImage = imageMap.get(k + "-3");
|
|
|
- if (StringUtils.isEmpty(productImage)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行商品图片不能为空";
|
|
|
- }
|
|
|
- // 校验授权牌照
|
|
|
- String certificateImage = imageMap.get(k + "-4");
|
|
|
- if (StringUtils.isEmpty(certificateImage)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行授权牌照不能为空";
|
|
|
- }
|
|
|
- List<ProductParamPo> paramList = new ArrayList<>();
|
|
|
- // 校验参数列表
|
|
|
- for (int a = 5; a + 1 < cellTotalNum; a += 2) {
|
|
|
- XSSFCell paramNameCell = productRow.getCell(a);
|
|
|
- XSSFCell paramContentCell = productRow.getCell(a + 1);
|
|
|
- boolean validName = null != paramNameCell;
|
|
|
- boolean validContent = null != paramContentCell;
|
|
|
- if (validName && validContent) {
|
|
|
- String paramName = paramNameCell.getStringCellValue();
|
|
|
- String paramContent = paramContentCell.getStringCellValue();
|
|
|
- validName = StringUtils.isNotEmpty(paramName);
|
|
|
- validContent = StringUtils.isNotEmpty(paramContent);
|
|
|
- if (validName && validContent) {
|
|
|
- ProductParamPo productParamPo = new ProductParamPo();
|
|
|
- productParamPo.setParamName(paramName);
|
|
|
- productParamPo.setParamContent(paramContent);
|
|
|
- paramList.add(productParamPo);
|
|
|
- } else if ((validName || validContent)) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
|
|
|
- }
|
|
|
- } else if (validName || validContent) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
|
|
|
- }
|
|
|
- }
|
|
|
- if (paramList.size() < 4) {
|
|
|
- errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数量不足";
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(errorReason)) {
|
|
|
- // 删除临时图片文件
|
|
|
- for (String image : imageMap.values()) {
|
|
|
- if (StringUtils.isNotEmpty(image)) {
|
|
|
- File tempFile = new File(image);
|
|
|
- tempFile.delete();
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ Integer checkCityId = authMapper.getCityIdByTownId(town.getTownId());
|
|
|
+ if (null != provinceId && null != checkCityId) {
|
|
|
+ Integer checkProvinceId = authMapper.getProvinceIdByCityId(cityId);
|
|
|
+ if (provinceId.equals(checkProvinceId)) {
|
|
|
+ cityId = checkCityId;
|
|
|
+ townId = town.getTownId();
|
|
|
}
|
|
|
- return ResponseJson.error(errorReason);
|
|
|
}
|
|
|
- /*
|
|
|
- 组装商品数据
|
|
|
- */
|
|
|
- ProductSaveDto product = new ProductSaveDto();
|
|
|
- // 品牌id
|
|
|
- product.setBrandId(brandId);
|
|
|
- // sn码
|
|
|
- product.setSnCode(snCode);
|
|
|
- // 商品图片
|
|
|
- product.setProductImage(uploadImage(productImage));
|
|
|
- // 授权牌照
|
|
|
- product.setCertificateImage(uploadImage(certificateImage));
|
|
|
- // 参数列表
|
|
|
- product.setParamList(paramList);
|
|
|
- // 创建人
|
|
|
- product.setCreateBy(createBy);
|
|
|
- productList.add(product);
|
|
|
- tempImageList.add(productImage);
|
|
|
- tempImageList.add(certificateImage);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 授权机构
|
|
|
- authImportPo.setAuthParty(authParty);
|
|
|
- // 商品列表
|
|
|
- authImportPo.setProductList(productList);
|
|
|
- // 添加数据
|
|
|
- authImportList.add(authImportPo);
|
|
|
}
|
|
|
+ // 校验详细地址
|
|
|
+ cell = authPartyRow.getCell(2);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String address = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isBlank(address)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行详细地址不能为空");
|
|
|
+ }
|
|
|
+ // 校验经纬度
|
|
|
+ cell = authPartyRow.getCell(3);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String lngAndLat = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isBlank(lngAndLat)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行经纬度不能为空");
|
|
|
+ }
|
|
|
+ String[] split = lngAndLat.split(",");
|
|
|
+ if (2 != split.length) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行经纬度格式错误");
|
|
|
+ }
|
|
|
+ BigDecimal lng = new BigDecimal(split[0]);
|
|
|
+ BigDecimal lat = new BigDecimal(split[1]);
|
|
|
+ // 校验联系电话
|
|
|
+ cell = authPartyRow.getCell(4);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String mobile = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isBlank(mobile)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行联系电话不能为空");
|
|
|
+ }
|
|
|
+ // 认证编号
|
|
|
+ cell = authPartyRow.getCell(5);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String authCode = cell.getStringCellValue();
|
|
|
+ // 认证日期
|
|
|
+ Date authDate = null;
|
|
|
+ cell = authPartyRow.getCell(6);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String authDateStr = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isNotBlank(authDateStr)) {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
+ authDate = format.parse(authDateStr);
|
|
|
+ }
|
|
|
+ // 校验员工人数
|
|
|
+ Integer empNum = null;
|
|
|
+ cell = authPartyRow.getCell(7);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String empNumStr = cell.getStringCellValue();
|
|
|
+ if (StringUtils.isBlank(empNumStr)) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行员工人数不能为空");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ empNum = Integer.parseInt(empNumStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResponseJson.error("第" + i + 1 + "行员工人数格式错误");
|
|
|
+ }
|
|
|
+ // 校验店铺备注
|
|
|
+ cell = authPartyRow.getCell(8);
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ String remarks = cell.getStringCellValue();
|
|
|
+ Integer customFlag = 0;
|
|
|
+ if (StringUtils.isNotEmpty(remarks)) {
|
|
|
+ customFlag = 1;
|
|
|
+ }
|
|
|
+ CmBrandAuthPo authPo = new CmBrandAuthPo();
|
|
|
+ authPo.setAuthParty(authParty);
|
|
|
+ authPo.setProvinceId(provinceId);
|
|
|
+ authPo.setCityId(cityId);
|
|
|
+ authPo.setTownId(townId);
|
|
|
+ authPo.setAddress(address);
|
|
|
+ authPo.setLng(lng);
|
|
|
+ authPo.setLat(lat);
|
|
|
+ authPo.setMobile(mobile);
|
|
|
+ authPo.setAuthCode(authCode);
|
|
|
+ authPo.setAuthDate(authDate);
|
|
|
+ authPo.setAuthImageType(1);
|
|
|
+ authPo.setEmpNum(empNum);
|
|
|
+ authPo.setCustomFlag(customFlag);
|
|
|
+ authPo.setRemarks(remarks);
|
|
|
+ authImportList.add(authPo);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -716,337 +672,24 @@ public class AuthServiceImpl implements AuthService {
|
|
|
File tempFile = new File(filePath);
|
|
|
boolean delete = tempFile.delete();
|
|
|
log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时表格:" + delete);
|
|
|
- tempImageList.forEach(tempImagePath->{
|
|
|
- File tempImage = new File(tempImagePath);
|
|
|
- boolean del = tempImage.delete();
|
|
|
- log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时商品图片:" + del);
|
|
|
- });
|
|
|
}
|
|
|
// 保存授权数据
|
|
|
- authImportList.forEach(authImportPo -> {
|
|
|
- String authParty = authImportPo.getAuthParty();
|
|
|
- List<ProductSaveDto> productList = authImportPo.getProductList();
|
|
|
- Integer authId = authMapper.getAuthIdByAuthParty(authParty, authUserId);
|
|
|
+ for (int i = 0; i < authImportList.size(); i++) {
|
|
|
+ CmBrandAuthPo authPo = authImportList.get(i);
|
|
|
// 保存授权机构
|
|
|
- if (null == authId) {
|
|
|
- CmBrandAuthPo auth = new CmBrandAuthPo();
|
|
|
- auth.setAuthUserId(authUserId);
|
|
|
- auth.setAuthParty(authParty);
|
|
|
- auth.setCreateBy(createBy);
|
|
|
- // 导入数据
|
|
|
- ResponseJson responseJson = saveAuth(auth, null, true, 1);
|
|
|
- CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
|
|
|
- authId = authPo.getId();
|
|
|
+ authPo.setAuthUserId(authUserId);
|
|
|
+ authPo.setCreateBy(createBy);
|
|
|
+ authPo.setCreateSource(1);
|
|
|
+ authPo.setFirstClubType(5);
|
|
|
+ // 导入数据
|
|
|
+ ResponseJson result = saveAuth(authPo, null, true, 1);
|
|
|
+ if (result.getCode() != 0) {
|
|
|
+ // 设置手动回滚事务
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return ResponseJson.error("导入失败");
|
|
|
}
|
|
|
- Integer finalAuthId = authId;
|
|
|
- // 保存商品列表
|
|
|
- productList.forEach(productDto -> {
|
|
|
- try {
|
|
|
- productDto.setAuthId(finalAuthId);
|
|
|
- // 上传商品图片和授权牌照
|
|
|
- String productImage = productDto.getProductImage();
|
|
|
- String certificateImage = productDto.getCertificateImage();
|
|
|
- productDto.setProductImage(productImage);
|
|
|
- productDto.setCertificateImage(certificateImage);
|
|
|
- productDto.setSource(1);
|
|
|
- authProductService.saveProduct(productDto, true);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- return ResponseJson.success("导入成功");
|
|
|
- }
|
|
|
-
|
|
|
- private ResponseJson exportData(List<CmBrandAuthPo> authPartyList, OutputStream outputStream) {
|
|
|
- try {
|
|
|
- HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
- // 创建机构工作表
|
|
|
- HSSFSheet authPartySheet = workbook.createSheet("授权机构");
|
|
|
- // sheet样式定义
|
|
|
- HSSFCellStyle topCellStyle = this.getTopCellStyle(workbook);
|
|
|
- HSSFCellStyle customCellStyle = this.getCustomCellStyle(workbook);
|
|
|
- // 创建列头行
|
|
|
- HSSFRow topRow = authPartySheet.createRow(0);
|
|
|
- HSSFCell topRowCell = topRow.createCell(0);
|
|
|
- topRowCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- HSSFRichTextString text = new HSSFRichTextString("授权机构");
|
|
|
- topRowCell.setCellValue(text);
|
|
|
- topRowCell.setCellStyle(topCellStyle);
|
|
|
- // 行索引
|
|
|
- AtomicInteger authPartyRowNum = new AtomicInteger(1);
|
|
|
- // 每个机构创建一行数据
|
|
|
- authPartyList.forEach(authParty -> {
|
|
|
- HSSFRow authPartyRow = authPartySheet.createRow(authPartyRowNum.get());
|
|
|
- HSSFCell authPartyCell = authPartyRow.createCell(0);
|
|
|
- authPartyCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- HSSFRichTextString authPartyName = new HSSFRichTextString(authParty.getAuthParty().trim());
|
|
|
- authPartyCell.setCellValue(authPartyName);
|
|
|
- authPartyCell.setCellStyle(customCellStyle);
|
|
|
- authPartyRowNum.getAndIncrement();
|
|
|
- });
|
|
|
- // 让列宽随着导出的列长自动适应
|
|
|
- int columnWidth = authPartySheet.getColumnWidth(0) / 256;
|
|
|
- for (int rowNum = 0; rowNum < authPartySheet.getLastRowNum(); rowNum++) {
|
|
|
- HSSFRow currentRow;
|
|
|
- // 当前行未被使用过
|
|
|
- if (authPartySheet.getRow(rowNum) == null) {
|
|
|
- currentRow = authPartySheet.createRow(rowNum);
|
|
|
- } else {
|
|
|
- currentRow = authPartySheet.getRow(rowNum);
|
|
|
- }
|
|
|
- if (currentRow.getCell(0) != null) {
|
|
|
- HSSFCell currentCell = currentRow.getCell(0);
|
|
|
- if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
|
|
|
- int length = currentCell.getStringCellValue()
|
|
|
- .getBytes().length;
|
|
|
- if (columnWidth < length) {
|
|
|
- columnWidth = length;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- authPartySheet.setColumnWidth(0, (columnWidth + 4) * 256);
|
|
|
- List<String> sheetNameList = new ArrayList<>();
|
|
|
- // 创建每个机构对应的商品表
|
|
|
- authPartyList.forEach(authParty -> {
|
|
|
- // 授权机构名称作为表名
|
|
|
- String productSheetName = authParty.getAuthParty();
|
|
|
- // 商品列表
|
|
|
- List<ProductFormVo> productList = authParty.getProductList();
|
|
|
- // 创建商品工作表
|
|
|
- int k = 1;
|
|
|
- while (sheetNameList.contains(productSheetName)) {
|
|
|
- productSheetName = productSheetName.replace("(" + (k-1) + ")", "") + "(" + k + ")";
|
|
|
- k++;
|
|
|
- }
|
|
|
- sheetNameList.add(productSheetName);
|
|
|
- HSSFSheet productSheet = workbook.createSheet(productSheetName);
|
|
|
- // 创建列头行
|
|
|
- HSSFRow productTopRow = productSheet.createRow(0);
|
|
|
- // 添加列头单元格(5个固定列+参数列表)
|
|
|
- String[] rowName = {"商品名称", "商品SN码", "所属品牌", "商品图片(尺寸:128px×88px)",
|
|
|
- "授权牌(尺寸:128px×88px)", "参数名称1", "参数值1", "参数名称2", "参数值2", "参数名称3",
|
|
|
- "参数值3", "参数名称4", "参数值4", "参数名称5", "参数值5", "参数名称6", "参数值6", "参数名称7",
|
|
|
- "参数值7", "参数名称8", "参数值8", "参数名称9", "参数值9", "参数名称10", "参数值10", "参数名称11",
|
|
|
- "参数值11", "参数名称12", "参数值12"};
|
|
|
- for (int i = 0; i < 5 + (0 == authParty.getMaxParamNum() ? 4 : authParty.getMaxParamNum()) * 2; i++) {
|
|
|
- HSSFCell productTopRowCell = productTopRow.createCell(i);
|
|
|
- productTopRowCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- HSSFRichTextString columnText = new HSSFRichTextString(rowName[i]);
|
|
|
- productTopRowCell.setCellValue(columnText);
|
|
|
- productTopRowCell.setCellStyle(topCellStyle);
|
|
|
- }
|
|
|
- // 添加商品数据到单元格中
|
|
|
- // 行索引
|
|
|
- AtomicInteger productRowNum = new AtomicInteger(1);
|
|
|
- productList.forEach(product -> {
|
|
|
- // 创建商品行
|
|
|
- HSSFRow productRow = productSheet.createRow(productRowNum.get());
|
|
|
- // 设置行高度
|
|
|
- productRow.setHeight((short) 2200);
|
|
|
- // 参数列表
|
|
|
- List<ProductParamPo> paramList = product.getParamList();
|
|
|
- // 组装商品数据
|
|
|
- List<String> productData = new ArrayList<>();
|
|
|
- productData.add(product.getProductName());
|
|
|
- productData.add(product.getSnCode());
|
|
|
- productData.add(product.getBrandName());
|
|
|
- productData.add(product.getProductImage());
|
|
|
- productData.add(product.getCertificateImage());
|
|
|
- paramList.forEach(param -> {
|
|
|
- productData.add(param.getParamName());
|
|
|
- productData.add(param.getParamContent());
|
|
|
- });
|
|
|
- for (int j = 0; j < 5 + paramList.size() * 2; j++) {
|
|
|
- HSSFCell productCell = productRow.createCell(j);
|
|
|
- if (j == 3 || j == 4) {
|
|
|
-// productSheet.addMergedRegion(new CellRangeAddress(j + 1,j + 1,j + 1,j + 1)) ;
|
|
|
- // 头像
|
|
|
- String imageUrl = productData.get(j);
|
|
|
- if (StringUtils.isNotEmpty(imageUrl)) {
|
|
|
-
|
|
|
- String fileType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
|
|
|
- InputStream imageStream = getImageStream(imageUrl);
|
|
|
- if (null != imageStream) {
|
|
|
- try {
|
|
|
- BufferedImage bufferedImage = ImageIO.read(imageStream);
|
|
|
- ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(bufferedImage, fileType, byteArrayOut);
|
|
|
- byte[] data = byteArrayOut.toByteArray();
|
|
|
- HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
|
|
|
- // 设置图片位置
|
|
|
- HSSFClientAnchor anchor = new HSSFClientAnchor(30, 30, 700, 200, (short) j, productRowNum.get(), (short) j, productRowNum.get());
|
|
|
- drawingPatriarch.createPicture(anchor, workbook.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- } else {
|
|
|
- productCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- productCell.setCellValue("");
|
|
|
- }
|
|
|
- } else {
|
|
|
- productCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- productCell.setCellValue("");
|
|
|
- }
|
|
|
- } else {
|
|
|
- productCell.setCellType(CellType.valueOf("STRING"));
|
|
|
- HSSFRichTextString productCellValue = new HSSFRichTextString(productData.get(j));
|
|
|
- productCell.setCellValue(productCellValue);
|
|
|
- productCell.setCellStyle(customCellStyle);
|
|
|
- }
|
|
|
- }
|
|
|
- productRowNum.getAndIncrement();
|
|
|
- });
|
|
|
-
|
|
|
- // 让列宽随着导出的列长自动适应
|
|
|
- for (int colNum = 0; (colNum < 5 + authParty.getMaxParamNum() * 2); colNum++) {
|
|
|
- if (colNum == 3 || colNum == 4) {
|
|
|
- productSheet.setColumnWidth(colNum, 8200);
|
|
|
- } else {
|
|
|
- int productColumnWidth = productSheet.getColumnWidth(colNum) / 256;
|
|
|
- for (int rowNum = 0; rowNum < productSheet.getLastRowNum(); rowNum++) {
|
|
|
- HSSFRow currentRow;
|
|
|
- // 当前行未被使用过
|
|
|
- if (productSheet.getRow(rowNum) == null) {
|
|
|
- currentRow = productSheet.createRow(rowNum);
|
|
|
- } else {
|
|
|
- currentRow = productSheet.getRow(rowNum);
|
|
|
- }
|
|
|
- if (currentRow.getCell(colNum) != null) {
|
|
|
- HSSFCell currentCell = currentRow.getCell(colNum);
|
|
|
- if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
|
|
|
- int length = currentCell.getStringCellValue()
|
|
|
- .getBytes().length;
|
|
|
- if (productColumnWidth < length) {
|
|
|
- productColumnWidth = length;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- productSheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- outputStream.flush();
|
|
|
- workbook.write(outputStream);
|
|
|
- outputStream.close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return ResponseJson.error("导出失败");
|
|
|
}
|
|
|
- return ResponseJson.success("导出成功");
|
|
|
- }
|
|
|
-
|
|
|
- private String uploadImage(String filePath) throws IOException {
|
|
|
- // 临时图片
|
|
|
- File tempFile = new File(filePath);
|
|
|
- log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
|
|
|
- String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
|
|
|
- return imageUrl;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 列头单元格样式
|
|
|
- */
|
|
|
- private HSSFCellStyle getTopCellStyle(HSSFWorkbook workbook) {
|
|
|
-
|
|
|
- // 设置字体
|
|
|
- HSSFFont font = workbook.createFont();
|
|
|
- // 设置字体大小
|
|
|
- font.setFontHeightInPoints((short) 11);
|
|
|
- // 字体加粗
|
|
|
- font.setBold(true);
|
|
|
- // 设置字体名字
|
|
|
- font.setFontName("Courier New");
|
|
|
- // 设置样式;
|
|
|
- HSSFCellStyle style = workbook.createCellStyle();
|
|
|
- // 设置底边框;
|
|
|
- style.setBorderBottom(BorderStyle.THIN);
|
|
|
- // 设置底边框颜色;
|
|
|
- style.setBottomBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置左边框;
|
|
|
- style.setBorderLeft(BorderStyle.THIN);
|
|
|
- // 设置左边框颜色;
|
|
|
- style.setLeftBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置右边框;
|
|
|
- style.setBorderRight(BorderStyle.THIN);
|
|
|
- // 设置右边框颜色;
|
|
|
- style.setRightBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置顶边框;
|
|
|
- style.setBorderTop(BorderStyle.THIN);
|
|
|
- // 设置顶边框颜色;
|
|
|
- style.setTopBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 在样式用应用设置的字体;
|
|
|
- style.setFont(font);
|
|
|
- // 设置自动换行;
|
|
|
- style.setWrapText(false);
|
|
|
- // 设置水平对齐的样式为居中对齐;
|
|
|
- style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- // 设置垂直对齐的样式为居中对齐;
|
|
|
- style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
-
|
|
|
- return style;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 列数据信息单元格样式
|
|
|
- */
|
|
|
- private HSSFCellStyle getCustomCellStyle(HSSFWorkbook workbook) {
|
|
|
- // 设置字体
|
|
|
- HSSFFont font = workbook.createFont();
|
|
|
- // 设置字体大小
|
|
|
- // font.setFontHeightInPoints((short)10);
|
|
|
- // 字体加粗
|
|
|
- // font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
|
|
- // 设置字体名字
|
|
|
- font.setFontName("Courier New");
|
|
|
- // 设置样式;
|
|
|
- HSSFCellStyle style = workbook.createCellStyle();
|
|
|
- // 设置底边框;
|
|
|
- style.setBorderBottom(BorderStyle.THIN);
|
|
|
- // 设置底边框颜色;
|
|
|
- style.setBottomBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置左边框;
|
|
|
- style.setBorderLeft(BorderStyle.THIN);
|
|
|
- // 设置左边框颜色;
|
|
|
- style.setLeftBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置右边框;
|
|
|
- style.setBorderRight(BorderStyle.THIN);
|
|
|
- // 设置右边框颜色;
|
|
|
- style.setRightBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 设置顶边框;
|
|
|
- style.setBorderTop(BorderStyle.THIN);
|
|
|
- // 设置顶边框颜色;
|
|
|
- style.setTopBorderColor(IndexedColors.BLACK.index);
|
|
|
- // 在样式用应用设置的字体;
|
|
|
- style.setFont(font);
|
|
|
- // 设置自动换行;
|
|
|
- style.setWrapText(false);
|
|
|
- // 设置水平对齐的样式为居中对齐;
|
|
|
- style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- // 设置垂直对齐的样式为居中对齐;
|
|
|
- style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- return style;
|
|
|
+ return ResponseJson.success("导入成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public InputStream getImageStream(String url) {
|
|
|
- try {
|
|
|
- HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
|
|
- connection.setReadTimeout(5000);
|
|
|
- connection.setConnectTimeout(5000);
|
|
|
- connection.setRequestMethod("GET");
|
|
|
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
|
|
- InputStream inputStream = connection.getInputStream();
|
|
|
- return inputStream;
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- System.out.println("获取网络图片出现异常,图片路径为:" + url);
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
}
|