Commit 78fcf6eb authored by hongguangwu's avatar hongguangwu

Merge branch 'develop'

parents d4d50a90 95982635
...@@ -159,35 +159,125 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -159,35 +159,125 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
Integer rowIndex = readRowHolder.getRowIndex(); Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1); data.setRowIndex(rowIndex + 1);
StringBuilder errorMessage = new StringBuilder(""); StringBuilder errorMessage = new StringBuilder("");
extracted(data, errorMessage);
if(data.isErrorFlag()){
data.setErrorMessage(errorMessage.toString());
}
tMinSalaryImportVoList.add(data);
}
@Override
public void doAfterAllAnalysed (AnalysisContext context){
saveData();
}
private void saveData () {
List<TMinSalaryImportVo> salaryImportsSuccessList = tMinSalaryImportVoList.stream().filter(e -> e.isErrorFlag() != true).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(salaryImportsSuccessList)) {
//将成功的数据转换成需要入库的格式
salaryImportsSuccessList.stream().forEach(e -> {
TMinSalary selectOne = new TMinSalary();
selectOne.setId(e.getId());
if (null != e.getLocation()) {
String location[] = e.getLocation().split("/");
if (location.length >1) {
for (int i = 0; i < location.length; i++) {
if (i == CommonConstants.ZERO_INT) {
int province = baseMapper.selectByAreaName(location[i]);
selectOne.setProvince(province);
}
if (i == CommonConstants.ONE_INT) {
int city = baseMapper.selectByAreaName(location[i]);
selectOne.setCity(city);
}
if (i == CommonConstants.TWO_INT) {
int town = baseMapper.selectByAreaName(location[i]);
selectOne.setTown(town);
}
}
}
}
if(null==e.getLocation()){
TMinSalary tMinSalary=baseMapper.selectById(e.getId());
selectOne.setProvince(tMinSalary.getProvince());
selectOne.setCity(tMinSalary.getCity());
selectOne.setTown(tMinSalary.getTown());
}
if(null!=e.getStatus()) {
if (CommonConstants.START.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.ONE_INT);
}
if (CommonConstants.STOP.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.TWO_INT);
}
}
if(null!=e.getSalaryBase()) {
selectOne.setSalaryBase(e.getSalaryBase());
}
selectOne.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(selectOne);
}
);
}
}
}).sheet().doRead();
} catch(
Exception e)
{
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
//返回给前端的错误数据
List<TMinSalaryImportVo> errorImportErrorList = tMinSalaryImportVoList.stream().filter(e -> e.isErrorFlag() == true).collect(Collectors.toList());
return R.ok(errorImportErrorList);
}
private void extracted(TMinSalaryImportVo data, StringBuilder errorMessage) {
if (Common.isEmpty(data.getId())) { if (Common.isEmpty(data.getId())) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("ID为空;"); errorMessage.append("ID为空;");
return;
} else { } else {
if (Common.isEmpty(baseMapper.selectById(data.getId()))) { if (Common.isEmpty(baseMapper.selectById(data.getId()))) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("ID不存在无法更新,请核实后再操作!;"); errorMessage.append("ID不存在无法更新,请核实后再操作!;");
return;
} }
if (Common.isEmpty(data.getLocation()) && Common.isEmpty(data.getSalaryBase()) && Common.isEmpty(data.getStatus())) { if (Common.isEmpty(data.getLocation()) && Common.isEmpty(data.getSalaryBase()) && Common.isEmpty(data.getStatus())) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("所在地、最低工资(元)、状态为空;"); errorMessage.append("所在地、最低工资(元)、状态为空;");
return;
} }
if(null!=data.getLocation()) { if(null!= data.getLocation()) {
if (data.getLocation().contains("-")) { if (data.getLocation().contains("-")) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("所在地格式与列表保持一致;"); errorMessage.append("所在地格式与列表保持一致;");
return;
}
} }
}else {
if (null != data.getLocation()) { if (null != data.getLocation()) {
String location[] = data.getLocation().split("/"); String location[] = data.getLocation().split("/");
if (!data.getLocation().isEmpty()) { if (!data.getLocation().isEmpty()) {
if (location.length == 1) { if (location.length == 1) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("所在地”请精确到市或县/区;"); errorMessage.append("所在地”请精确到市或县/区;");
return;
} }
String redisProvinceName = getRedisAreaValue(location[CommonConstants.ZERO_INT]); String redisProvinceName = getRedisAreaValue(location[CommonConstants.ZERO_INT]);
if (Common.isEmpty(redisProvinceName)) { if (Common.isEmpty(redisProvinceName)) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("对应区域不存在;"); errorMessage.append("对应区域不存在;");
return;
} }
} }
if (location.length == 2) { if (location.length == 2) {
...@@ -195,12 +285,13 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -195,12 +285,13 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
if (Common.isEmpty(redisProvinceName)) { if (Common.isEmpty(redisProvinceName)) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("对应区域不存在;"); errorMessage.append("对应区域不存在;");
return;
} }
String redisCityName = getRedisAreaValue(location[CommonConstants.ONE_INT] + "_" + location[CommonConstants.ZERO_INT]); String redisCityName = getRedisAreaValue(location[CommonConstants.ONE_INT] + "_" + location[CommonConstants.ZERO_INT]);
if (Common.isEmpty(redisCityName)) { if (Common.isEmpty(redisCityName)) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("对应区域不存在;"); errorMessage.append("对应区域不存在;");
return;
} else { } else {
TMinSalary entity = baseMapper.selectById(data.getId()); TMinSalary entity = baseMapper.selectById(data.getId());
if (Common.isNotNull(entity)) { if (Common.isNotNull(entity)) {
...@@ -219,7 +310,7 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -219,7 +310,7 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
if (res > CommonConstants.ZERO_INT) { if (res > CommonConstants.ZERO_INT) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("已存在对应区域在用的配置信息;"); errorMessage.append("已存在对应区域在用的配置信息;");
return;
} }
} }
} }
...@@ -230,12 +321,13 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -230,12 +321,13 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
if (Common.isEmpty(redisCityName)) { if (Common.isEmpty(redisCityName)) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("对应区域不存在;"); errorMessage.append("对应区域不存在;");
return;
} }
String redisTownName = getRedisAreaValue(location[CommonConstants.TWO_INT] + "_" + location[CommonConstants.ONE_INT]); String redisTownName = getRedisAreaValue(location[CommonConstants.TWO_INT] + "_" + location[CommonConstants.ONE_INT]);
if (Common.isEmpty(redisTownName)) { if (Common.isEmpty(redisTownName)) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("对应区域不存在;"); errorMessage.append("对应区域不存在;");
return;
} }
else { else {
TMinSalary entity = baseMapper.selectById(data.getId()); TMinSalary entity = baseMapper.selectById(data.getId());
...@@ -255,14 +347,15 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -255,14 +347,15 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
if (res > CommonConstants.ZERO_INT) { if (res > CommonConstants.ZERO_INT) {
data.setErrorFlag(true); data.setErrorFlag(true);
errorMessage.append("已存在对应区域在用的配置信息;"); errorMessage.append("已存在对应区域在用的配置信息;");
return;
}
} }
} }
} }
} }
} }
} }
if (Common.isNotNull(data)){
if (null != data.getSalaryBase()) { if (null != data.getSalaryBase()) {
if (!ValidityUtil.validateStandard(data.getSalaryBase())) { if (!ValidityUtil.validateStandard(data.getSalaryBase())) {
data.setErrorFlag(true); data.setErrorFlag(true);
...@@ -275,90 +368,9 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal ...@@ -275,90 +368,9 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
errorMessage.append("填写的状态不是启用或停用"); errorMessage.append("填写的状态不是启用或停用");
} }
} }
if(data.isErrorFlag())
{
data.setErrorMessage(errorMessage.toString());
}
tMinSalaryImportVoList.add(data);
}
@Override
public void doAfterAllAnalysed (AnalysisContext context){
saveData();
}
private void saveData () {
List<TMinSalaryImportVo> salaryImportsSuccessList = tMinSalaryImportVoList.stream().filter(e -> e.isErrorFlag() != true).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(salaryImportsSuccessList)) {
//将成功的数据转换成需要入库的格式
salaryImportsSuccessList.stream().forEach(e -> {
TMinSalary selectOne = new TMinSalary();
selectOne.setId(e.getId());
if (null != e.getLocation()) {
String location[] = e.getLocation().split("/");
if (location.length >1) {
for (int i = 0; i < location.length; i++) {
if (i == CommonConstants.ZERO_INT) {
int province = baseMapper.selectByAreaName(location[i]);
selectOne.setProvince(province);
}
if (i == CommonConstants.ONE_INT) {
int city = baseMapper.selectByAreaName(location[i]);
selectOne.setCity(city);
}
if (i == CommonConstants.TWO_INT) {
int town = baseMapper.selectByAreaName(location[i]);
selectOne.setTown(town);
}
}
}
}
if(null==e.getLocation()){
TMinSalary tMinSalary=baseMapper.selectById(e.getId());
selectOne.setProvince(tMinSalary.getProvince());
selectOne.setCity(tMinSalary.getCity());
selectOne.setTown(tMinSalary.getTown());
}
if(null!=e.getStatus()) {
if (CommonConstants.START.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.ONE_INT);
}
if (CommonConstants.STOP.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.TWO_INT);
}
}
if(null!=e.getSalaryBase()) {
selectOne.setSalaryBase(e.getSalaryBase());
}
selectOne.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(selectOne);
}
);
} }
} }
}).sheet().doRead();
} catch(
Exception e)
{
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
//返回给前端的错误数据
List<TMinSalaryImportVo> errorImportErrorList = tMinSalaryImportVoList.stream().filter(e -> e.isErrorFlag() == true).collect(Collectors.toList());
return R.ok(errorImportErrorList);
}
private String getRedisAreaValue(String areaString) { private String getRedisAreaValue(String areaString) {
return String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + areaString)); return String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + areaString));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment