Commit b4ba0add authored by zhenbin wang's avatar zhenbin wang

feature-wzb:check

parent 00d3b9a0
......@@ -40,17 +40,19 @@ public class TMinSalaryImportVo extends RowIndex implements Serializable {
/**
* TODO
*/
@ExcelProperty(value = "所在地")
private String location;
/**
* 省
*/
@ExcelAttribute(name = "所在地-省", isArea = true)
@HeadFontStyle(fontHeightInPoints = 11)
private Integer province;
/**
* 市
*/
@ExcelAttribute(name = "户籍所在市", isArea = true, parentField = "province")
@HeadFontStyle(fontHeightInPoints = 11)
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Integer city;
......@@ -58,23 +60,24 @@ public class TMinSalaryImportVo extends RowIndex implements Serializable {
/**
* 县
*/
@ExcelAttribute(name = "户籍所在市", isArea = true, parentField = "city")
@HeadFontStyle(fontHeightInPoints = 11)
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Integer town;
/**
* 最低工资标准
*/
@NotBlank(message = "最低工资标准不能为空")
@Length(max = 11, message = "最低工资标准不能超过11个字符")
@ExcelAttribute(name = "最低工资(元)", isNotEmpty = true, errorInfo = "最低工资标准不能为空", maxLength = 11)
@ExcelAttribute(name = "最低工资(元)", maxLength = 11)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "最低工资(元)")
private String salaryBase;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@ExcelAttribute(name = "状态", isNotEmpty = true, errorInfo = "状态不能为空")
@ExcelAttribute(name = "状态")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "状态")
private String status;
......
......@@ -31,8 +31,8 @@ public interface TMinSalaryMapper extends BaseMapper<TMinSalary> {
/**
* 缴费库简单分页查询
* @param tMinSalary 缴费库
* 最低工资分页列表总数
* @param tMinSalary 最低工资标准
* @return
*/
Integer selectCountTMinSalary(@Param("tMinSalary") TMinSalarySearchVo tMinSalary);
......
......@@ -39,6 +39,13 @@ public interface TMinSalaryService extends IService<TMinSalary> {
R<Boolean> updateByIdDIy(TMinSalary tMinSalary);
/**
* 最低工资批量更新
*
* @author wzb
* @param inputStream
* @return {@link R}
*/
R importList(InputStream inputStream);
/**
......
......@@ -14,10 +14,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.util.ValidityUtil;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TMinSalary;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TMinSalaryMapper;
......@@ -51,7 +53,7 @@ import java.util.stream.Collectors;
* @Date 13:17 2022/8/6
* @Param
* @return
**/
**/
@Service("tMinSalaryService")
public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSalary> implements TMinSalaryService {
......@@ -131,8 +133,6 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
}
@Override
public List<TMinSalaryExportVo> exportList(TMinSalarySearchVo tMinSalary) {
return baseMapper.getTMinSalaryNoPage(tMinSalary);
......@@ -140,109 +140,143 @@ public class TMinSalaryServiceImpl extends ServiceImpl<TMinSalaryMapper, TMinSal
/**
* 最低工资导出
* 批量更新
*
* @author wzb
* @param inputStream
* @return {@link R}
* @author wzb
*/
@Override
public R importList(InputStream inputStream) {
List<TMinSalaryImportVo> tMinSalaryImportVoList = new ArrayList<>();
try {
EasyExcel.read(inputStream, TMinSalaryImportVo.class, new ReadListener<TMinSalaryImportVo>() {
@Override
public void invoke(TMinSalaryImportVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
StringBuilder errorMessage = new StringBuilder("");
if (Common.isEmpty(data.getId())) {
data.setErrorFlag(true);
errorMessage.append("更新的ID为空;");
}
if (Common.isEmpty(data.getLocation())) {
data.setErrorFlag(true);
errorMessage.append("所在地为空;");
}
if (Common.isEmpty(data.getSalaryBase())) {
data.setErrorFlag(true);
errorMessage.append("最低工资标准为空;");
}
if (Common.isEmpty(data.getStatus())) {
data.setErrorFlag(true);
errorMessage.append("状态为空;");
}
if (CommonConstants.ZERO_INT==baseMapper.selectId(data.getId())) {
data.setErrorFlag(true);
errorMessage.append("不是系统内的数据;");
}
if (data.isErrorFlag()){
data.setErrorMessage(errorMessage.toString());
@Override
public R importList(InputStream inputStream) {
List<TMinSalaryImportVo> tMinSalaryImportVoList = new ArrayList<>();
try {
EasyExcel.read(inputStream, TMinSalaryImportVo.class, new ReadListener<TMinSalaryImportVo>() {
@Override
public void invoke(TMinSalaryImportVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
StringBuilder errorMessage = new StringBuilder("");
if (Common.isEmpty(data.getId())) {
data.setErrorFlag(true);
errorMessage.append("ID为空;");
}
if (Common.isEmpty(data.getLocation())&&Common.isEmpty(data.getSalaryBase())&&Common.isEmpty(data.getStatus())){
data.setErrorFlag(true);
errorMessage.append("所在地、最低工资(元)、状态为空;");
}
if (CommonConstants.ZERO_INT == baseMapper.selectId(data.getId())) {
data.setErrorFlag(true);
errorMessage.append("ID不存在无法更新,请核实后再操作!;");
}
String location[] = data.getLocation().split("/");
String redisProvinceName = getRedisAreaValue(location[CommonConstants.ZERO_INT]);
if (Common.isEmpty(redisProvinceName)) {
data.setErrorFlag(true);
errorMessage.append("对应区域不存在;");
}
if(location.length>1) {
String redisCityName = getRedisAreaValue(location[CommonConstants.ONE_INT] + "_" + location[CommonConstants.ZERO_INT]);
if (Common.isEmpty(redisCityName)) {
data.setErrorFlag(true);
errorMessage.append("对应区域不存在;");
}
String redisTownName = getRedisAreaValue(location[CommonConstants.TWO_INT] + "_" + location[CommonConstants.ONE_INT]);
if (Common.isEmpty(redisTownName)) {
data.setErrorFlag(true);
errorMessage.append("对应区域不存在;");
}}
LambdaQueryWrapper<TMinSalary> query = new LambdaQueryWrapper<>();
query.ne(TMinSalary::getId, data.getId());
long res = baseMapper.selectCount(query);
if (res > CommonConstants.ZERO_INT) {
data.setErrorFlag(true);
errorMessage.append("已存在对应区域在用的配置信息;");
if(!data.getLocation().isEmpty()){
if (location.length == 1) {
data.setErrorFlag(true);
errorMessage.append("所在地”请精确到市或县/区;");
}
}
if(null !=data.getSalaryBase()) {
if (!ValidityUtil.validateStandard(data.getSalaryBase())) {
data.setErrorFlag(true);
errorMessage.append("最低工资,请填写>0的两位小数;");
}
}
if(!data.getStatus().isEmpty()) {
if (!(CommonConstants.START.equals(data.getStatus()) || CommonConstants.STOP.equals(data.getStatus()))) {
data.setErrorFlag(true);
errorMessage.append("填写的状态不是启用或停用");
}
}
if (data.isErrorFlag()) {
data.setErrorMessage(errorMessage.toString());
}
tMinSalaryImportVoList.add(data);
}
}
tMinSalaryImportVoList.add(data);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
@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());
String location[]=e.getLocation().split("/");
for (int i=0 ;i<location.length;i++){
if(i==0){
int province=baseMapper.selectByAreaName(location[i]);
selectOne.setProvince(province);
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());
String location[] = e.getLocation().split("/");
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 (i==1){
int city=baseMapper.selectByAreaName(location[i]);
selectOne.setCity(city);
if (CommonConstants.START.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.ONE_INT);
}
if (i==2){
int town=baseMapper.selectByAreaName(location[i]);
selectOne.setTown(town);;
if (CommonConstants.STOP.equals(e.getStatus())) {
selectOne.setStatus(CommonConstants.TWO_INT);
}
}
if(e.getStatus().equals("启用")){
selectOne.setStatus(CommonConstants.ONE_INT);
}
if(e.getStatus().equals("停用")) {
selectOne.setStatus(CommonConstants.TWO_INT);
}
selectOne.setSalaryBase(e.getSalaryBase());
selectOne.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(selectOne);
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);
}
}).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) {
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