修改导入为两个预读取和导入两个功能
This commit is contained in:
parent
129c2f4b01
commit
401699ba00
|
|
@ -63,29 +63,25 @@ public class StoreImportController {
|
||||||
return AjaxResult.success(tbTemplateService.getByAlias(templateAlias, null));
|
return AjaxResult.success(tbTemplateService.getByAlias(templateAlias, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo 导入商户 read
|
|
||||||
// todo 导入商户 save
|
@SysLog(value = "导入预读取", businessType = BusinessType.IMPORT)
|
||||||
|
@PostMapping("/read")
|
||||||
|
@RequiresPermissions("store:import:read")
|
||||||
|
public AjaxResult importRead(@RequestParam(value = "file") MultipartFile file)
|
||||||
|
{
|
||||||
|
|
||||||
|
return AjaxResult.success(ExcelUtils.read(file, StoreImportDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@SysLog(value = "导入", businessType = BusinessType.IMPORT)
|
@SysLog(value = "导入", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/import")
|
@PostMapping("/save")
|
||||||
@RequiresPermissions("store:import:import")
|
@RequiresPermissions("store:import:save")
|
||||||
public AjaxResult importStore(@RequestParam(defaultValue = "file") MultipartFile file)
|
public AjaxResult importStore(@RequestParam(value = "lists") List<StoreImportDTO> lists)
|
||||||
{
|
{
|
||||||
List<StoreImportDTO> read = ExcelUtils.read(file, StoreImportDTO.class);
|
return AjaxResult.success(storeImportService.saveList(lists));
|
||||||
List<StoreImport> storeImportList = assembleEntity(read);
|
|
||||||
|
|
||||||
return AjaxResult.success(storeImportService.saveBatch(storeImportList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<StoreImport> assembleEntity(List<StoreImportDTO> read){
|
|
||||||
List<StoreImport> storeImportList = Lists.newArrayList();
|
|
||||||
for (StoreImportDTO storeImportDTO: read){
|
|
||||||
StoreImport copy = BeanCopyUtils.copy(storeImportDTO, StoreImport.class);
|
|
||||||
copy.setDeptId(SecurityUtils.getDeptId());
|
|
||||||
storeImportList.add(copy);
|
|
||||||
}
|
|
||||||
return storeImportList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表确认导入查询
|
* 列表确认导入查询
|
||||||
|
|
@ -131,10 +127,10 @@ public class StoreImportController {
|
||||||
/**
|
/**
|
||||||
* 新增导入数据
|
* 新增导入数据
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/save")
|
@PostMapping(value = "/save/one")
|
||||||
@SysLog(value = "新增导入数据", businessType = BusinessType.INSERT)
|
@SysLog(value = "新增导入数据", businessType = BusinessType.INSERT)
|
||||||
@RequiresPermissions("store:import:save")
|
@RequiresPermissions("store:import:save")
|
||||||
public AjaxResult save(@RequestBody @Validated(Create.class) StoreImportQuery query)
|
public AjaxResult saveOne(@RequestBody @Validated(Create.class) StoreImportQuery query)
|
||||||
{
|
{
|
||||||
StoreImport storeImport = BeanCopyUtils.copy(query, StoreImport.class);
|
StoreImport storeImport = BeanCopyUtils.copy(query, StoreImport.class);
|
||||||
storeImport.setDeptId(SecurityUtils.getDeptId());
|
storeImport.setDeptId(SecurityUtils.getDeptId());
|
||||||
|
|
@ -155,7 +151,4 @@ public class StoreImportController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.chushang.common.mybatis.page.CommonParam;
|
import com.chushang.common.mybatis.page.CommonParam;
|
||||||
import com.chushang.common.mybatis.utils.PageResult;
|
import com.chushang.common.mybatis.utils.PageResult;
|
||||||
import com.chushang.inspection.project.dto.ProjectDTO;
|
import com.chushang.inspection.project.dto.ProjectDTO;
|
||||||
|
import com.chushang.inspection.terminal.dto.StoreImportDTO;
|
||||||
import com.chushang.inspection.terminal.po.StoreImport;
|
import com.chushang.inspection.terminal.po.StoreImport;
|
||||||
import com.chushang.inspection.terminal.query.StoreImportQuery;
|
import com.chushang.inspection.terminal.query.StoreImportQuery;
|
||||||
import com.chushang.inspection.terminal.query.StoreQuery;
|
import com.chushang.inspection.terminal.query.StoreQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @auther: zhao
|
* @auther: zhao
|
||||||
* @date: 2024/7/3 9:55
|
* @date: 2024/7/3 9:55
|
||||||
|
|
@ -20,4 +23,6 @@ public interface StoreImportService extends IService<StoreImport> {
|
||||||
|
|
||||||
int confimImport(Long[] ids);
|
int confimImport(Long[] ids);
|
||||||
|
|
||||||
|
int saveList(List<StoreImportDTO> dtoList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.chushang.common.mybatis.utils.PageResult;
|
||||||
import com.chushang.common.mybatis.utils.WrapperUtils;
|
import com.chushang.common.mybatis.utils.WrapperUtils;
|
||||||
import com.chushang.inspection.project.dto.ProjectDTO;
|
import com.chushang.inspection.project.dto.ProjectDTO;
|
||||||
import com.chushang.inspection.project.po.WrkProject;
|
import com.chushang.inspection.project.po.WrkProject;
|
||||||
|
import com.chushang.inspection.terminal.dto.StoreImportDTO;
|
||||||
import com.chushang.inspection.terminal.mapper.StoreImportMapper;
|
import com.chushang.inspection.terminal.mapper.StoreImportMapper;
|
||||||
import com.chushang.inspection.terminal.mapper.StoreMapper;
|
import com.chushang.inspection.terminal.mapper.StoreMapper;
|
||||||
import com.chushang.inspection.terminal.mapper.TerminalInsMapper;
|
import com.chushang.inspection.terminal.mapper.TerminalInsMapper;
|
||||||
|
|
@ -27,7 +28,10 @@ import com.chushang.inspection.terminal.service.StoreImportService;
|
||||||
import com.chushang.inspection.terminal.vo.StoreVO;
|
import com.chushang.inspection.terminal.vo.StoreVO;
|
||||||
import com.chushang.inspection.terminal.vo.TerminalVO;
|
import com.chushang.inspection.terminal.vo.TerminalVO;
|
||||||
import com.chushang.inspection.utils.BeanCopyUtils;
|
import com.chushang.inspection.utils.BeanCopyUtils;
|
||||||
|
import com.chushang.security.utils.SecurityUtils;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -72,7 +76,7 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
i++;
|
i++;
|
||||||
StoreImport storeImport = getById(id);
|
StoreImport storeImport = getById(id);
|
||||||
if(ObjectUtil.isEmpty(storeImport)){
|
if (ObjectUtil.isEmpty(storeImport)) {
|
||||||
throw new RuntimeException("导入失败");
|
throw new RuntimeException("导入失败");
|
||||||
}
|
}
|
||||||
Store store = BeanCopyUtils.copy(storeImport, Store.class);
|
Store store = BeanCopyUtils.copy(storeImport, Store.class);
|
||||||
|
|
@ -90,5 +94,21 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Async
|
||||||
|
public int saveList(List<StoreImportDTO> dtoList) {
|
||||||
|
for (StoreImportDTO storeImportDTO : dtoList) {
|
||||||
|
StoreImport copy = BeanCopyUtils.copy(storeImportDTO, StoreImport.class);
|
||||||
|
copy.setDeptId(SecurityUtils.getDeptId());
|
||||||
|
try {
|
||||||
|
save(copy);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("商户导入异常:{}", copy.getStoreName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue