|
@@ -28,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -304,12 +306,12 @@ public class AuthServiceImpl implements AuthService {
|
|
TemplateVo authTemplate = authMapper.getAuthTemplate(auth.getId(), null, 1);
|
|
TemplateVo authTemplate = authMapper.getAuthTemplate(auth.getId(), null, 1);
|
|
authImage = generateAuthImage(authTemplate, auth);
|
|
authImage = generateAuthImage(authTemplate, auth);
|
|
auth.setAuthImage(authImage);
|
|
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) {
|
|
if (null != bannerList) {
|
|
@@ -534,6 +536,7 @@ public class AuthServiceImpl implements AuthService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor=Exception.class)
|
|
private ResponseJson saveExcelData(String filePath, Integer authUserId, Integer createBy) {
|
|
private ResponseJson saveExcelData(String filePath, Integer authUserId, Integer createBy) {
|
|
//判断是否为excel类型文件
|
|
//判断是否为excel类型文件
|
|
if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx")) {
|
|
if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx")) {
|
|
@@ -565,13 +568,21 @@ public class AuthServiceImpl implements AuthService {
|
|
for (int i = 1; i <= authPartyRowNum; i++) {
|
|
for (int i = 1; i <= authPartyRowNum; i++) {
|
|
//获得第i行对象
|
|
//获得第i行对象
|
|
Row authPartyRow = authPartySheet.getRow(i);
|
|
Row authPartyRow = authPartySheet.getRow(i);
|
|
|
|
+ if (null == authPartyRow) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ Cell cell = null;
|
|
// 校验机构名称
|
|
// 校验机构名称
|
|
- String authParty = authPartyRow.getCell(0).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(0);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String authParty = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(authParty)) {
|
|
if (StringUtils.isBlank(authParty)) {
|
|
return ResponseJson.error("第" + i + 1 + "行机构名称不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行机构名称不能为空");
|
|
}
|
|
}
|
|
// 校验省市区
|
|
// 校验省市区
|
|
- String area = authPartyRow.getCell(1).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(1);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String area = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(area)) {
|
|
if (StringUtils.isBlank(area)) {
|
|
return ResponseJson.error("第" + i + 1 + "行所在地区不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行所在地区不能为空");
|
|
}
|
|
}
|
|
@@ -605,7 +616,7 @@ public class AuthServiceImpl implements AuthService {
|
|
townName = townName.substring(0, townName.length() - 1).trim();
|
|
townName = townName.substring(0, townName.length() - 1).trim();
|
|
}
|
|
}
|
|
List<TownPo> townList = authMapper.getTownList(townName);
|
|
List<TownPo> townList = authMapper.getTownList(townName);
|
|
- for (int j = 0; j < townList.size(); i++) {
|
|
|
|
|
|
+ for (int j = 0; j < townList.size(); j++) {
|
|
TownPo town = townList.get(j);
|
|
TownPo town = townList.get(j);
|
|
if (null == townId) {
|
|
if (null == townId) {
|
|
if (null != cityId) {
|
|
if (null != cityId) {
|
|
@@ -626,12 +637,16 @@ public class AuthServiceImpl implements AuthService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 校验详细地址
|
|
// 校验详细地址
|
|
- String address = authPartyRow.getCell(2).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(2);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String address = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(address)) {
|
|
if (StringUtils.isBlank(address)) {
|
|
return ResponseJson.error("第" + i + 1 + "行详细地址不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行详细地址不能为空");
|
|
}
|
|
}
|
|
// 校验经纬度
|
|
// 校验经纬度
|
|
- String lngAndLat = authPartyRow.getCell(3).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(3);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String lngAndLat = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(lngAndLat)) {
|
|
if (StringUtils.isBlank(lngAndLat)) {
|
|
return ResponseJson.error("第" + i + 1 + "行经纬度不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行经纬度不能为空");
|
|
}
|
|
}
|
|
@@ -642,22 +657,30 @@ public class AuthServiceImpl implements AuthService {
|
|
BigDecimal lng = new BigDecimal(split[0]);
|
|
BigDecimal lng = new BigDecimal(split[0]);
|
|
BigDecimal lat = new BigDecimal(split[1]);
|
|
BigDecimal lat = new BigDecimal(split[1]);
|
|
// 校验联系电话
|
|
// 校验联系电话
|
|
- String mobile = authPartyRow.getCell(4).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(4);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String mobile = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(mobile)) {
|
|
if (StringUtils.isBlank(mobile)) {
|
|
return ResponseJson.error("第" + i + 1 + "行联系电话不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行联系电话不能为空");
|
|
}
|
|
}
|
|
// 认证编号
|
|
// 认证编号
|
|
- String authCode = authPartyRow.getCell(5).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(5);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String authCode = cell.getStringCellValue();
|
|
// 认证日期
|
|
// 认证日期
|
|
Date authDate = null;
|
|
Date authDate = null;
|
|
- String authDateStr = authPartyRow.getCell(6).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(6);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String authDateStr = cell.getStringCellValue();
|
|
if (StringUtils.isNotBlank(authDateStr)) {
|
|
if (StringUtils.isNotBlank(authDateStr)) {
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
|
|
authDate = format.parse(authDateStr);
|
|
authDate = format.parse(authDateStr);
|
|
}
|
|
}
|
|
// 校验员工人数
|
|
// 校验员工人数
|
|
Integer empNum = null;
|
|
Integer empNum = null;
|
|
- String empNumStr = authPartyRow.getCell(7).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(7);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String empNumStr = cell.getStringCellValue();
|
|
if (StringUtils.isBlank(empNumStr)) {
|
|
if (StringUtils.isBlank(empNumStr)) {
|
|
return ResponseJson.error("第" + i + 1 + "行员工人数不能为空");
|
|
return ResponseJson.error("第" + i + 1 + "行员工人数不能为空");
|
|
}
|
|
}
|
|
@@ -667,7 +690,9 @@ public class AuthServiceImpl implements AuthService {
|
|
return ResponseJson.error("第" + i + 1 + "行员工人数格式错误");
|
|
return ResponseJson.error("第" + i + 1 + "行员工人数格式错误");
|
|
}
|
|
}
|
|
// 校验店铺备注
|
|
// 校验店铺备注
|
|
- String remarks = authPartyRow.getCell(6).getStringCellValue();
|
|
|
|
|
|
+ cell = authPartyRow.getCell(8);
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
+ String remarks = cell.getStringCellValue();
|
|
Integer customFlag = 0;
|
|
Integer customFlag = 0;
|
|
if (StringUtils.isNotEmpty(remarks)) {
|
|
if (StringUtils.isNotEmpty(remarks)) {
|
|
customFlag = 1;
|
|
customFlag = 1;
|
|
@@ -681,6 +706,9 @@ public class AuthServiceImpl implements AuthService {
|
|
authPo.setLng(lng);
|
|
authPo.setLng(lng);
|
|
authPo.setLat(lat);
|
|
authPo.setLat(lat);
|
|
authPo.setMobile(mobile);
|
|
authPo.setMobile(mobile);
|
|
|
|
+ authPo.setAuthCode(authCode);
|
|
|
|
+ authPo.setAuthDate(authDate);
|
|
|
|
+ authPo.setAuthImageType(1);
|
|
authPo.setEmpNum(empNum);
|
|
authPo.setEmpNum(empNum);
|
|
authPo.setCustomFlag(customFlag);
|
|
authPo.setCustomFlag(customFlag);
|
|
authPo.setRemarks(remarks);
|
|
authPo.setRemarks(remarks);
|
|
@@ -696,14 +724,20 @@ public class AuthServiceImpl implements AuthService {
|
|
log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时表格:" + delete);
|
|
log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时表格:" + delete);
|
|
}
|
|
}
|
|
// 保存授权数据
|
|
// 保存授权数据
|
|
- authImportList.forEach(authPo -> {
|
|
|
|
|
|
+ for (int i = 0; i < authImportList.size(); i++) {
|
|
|
|
+ CmBrandAuthPo authPo = authImportList.get(i);
|
|
// 保存授权机构
|
|
// 保存授权机构
|
|
- CmBrandAuthPo auth = new CmBrandAuthPo();
|
|
|
|
- auth.setAuthUserId(authUserId);
|
|
|
|
- auth.setCreateBy(createBy);
|
|
|
|
|
|
+ authPo.setAuthUserId(authUserId);
|
|
|
|
+ authPo.setCreateBy(createBy);
|
|
|
|
+ authPo.setFirstClubType(5);
|
|
// 导入数据
|
|
// 导入数据
|
|
- ResponseJson responseJson = saveAuth(auth, null, true, 1);
|
|
|
|
- });
|
|
|
|
|
|
+ ResponseJson result = saveAuth(authPo, null, true, 1);
|
|
|
|
+ if (result.getCode() != 0) {
|
|
|
|
+ // 设置手动回滚事务
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
+ return ResponseJson.error("导入失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return ResponseJson.success("导入成功");
|
|
return ResponseJson.success("导入成功");
|
|
}
|
|
}
|
|
|
|
|