修改导入商户逻辑为直接导入
This commit is contained in:
parent
a7bd8a00bd
commit
5d2d44b268
|
|
@ -153,7 +153,7 @@ public class StoreImportDTO implements Serializable {
|
|||
*/
|
||||
@ExcelProperty(value = "pos编号")
|
||||
@Size(max = 50, message = "操作员编号不能大于50个字符")
|
||||
private String userName;
|
||||
private String adminIds;
|
||||
/**
|
||||
* 客户经理
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,77 +78,14 @@ public class StoreImportController {
|
|||
@RequiresPermissions("store:import:save")
|
||||
public AjaxResult importStore(@RequestBody List<StoreImportDTO> lists)
|
||||
{
|
||||
storeImportService.saveList(lists);
|
||||
return AjaxResult.success();
|
||||
return AjaxResult.success(storeImportService.confimImport(lists));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表确认导入查询
|
||||
*
|
||||
* @param query 条件
|
||||
*/
|
||||
@SysLog(value = "列表确认导入查询", businessType = BusinessType.QUERY)
|
||||
@GetMapping("/page")
|
||||
@RequiresPermissions("store:import:page")
|
||||
public AjaxResult pageList(@Validated StoreImportQuery query) {
|
||||
CommonParam commonParam = CommonParam.buildPageRequest();
|
||||
return AjaxResult.success(storeImportService.pageList(query,commonParam));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改 商户确认导入
|
||||
*/
|
||||
@PostMapping(value = "/update")
|
||||
@RequiresPermissions("store:import:update")
|
||||
@SysLog(value = "导入数据删除",businessType = BusinessType.UPDATE)
|
||||
public AjaxResult update(@RequestBody @Validated(Update.class) StoreImportQuery query){
|
||||
|
||||
StoreImport storeImport = BeanCopyUtils.copy(query, StoreImport.class);
|
||||
storeImport.setDeptId(SecurityUtils.getDeptId());
|
||||
return AjaxResult.success(storeImportService.updateById(storeImport));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除导入数据
|
||||
*/
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@RequiresPermissions("store:import:del")
|
||||
@SysLog(value = "导入数据删除",businessType = BusinessType.DELETE)
|
||||
public AjaxResult delProject( @PathVariable Long[] ids)
|
||||
{
|
||||
return AjaxResult.success(storeImportService.removeByIds(Arrays.asList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增导入数据
|
||||
*/
|
||||
@PostMapping(value = "/save/one")
|
||||
@SysLog(value = "新增导入数据", businessType = BusinessType.INSERT)
|
||||
@RequiresPermissions("store:import:save")
|
||||
public AjaxResult saveOne(@RequestBody @Validated(Create.class) StoreImportQuery query)
|
||||
{
|
||||
StoreImport storeImport = BeanCopyUtils.copy(query, StoreImport.class);
|
||||
storeImport.setDeptId(SecurityUtils.getDeptId());
|
||||
return AjaxResult.success(storeImportService.save(storeImport));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 确认导入数据
|
||||
*/
|
||||
@GetMapping(value = "/confirm/{ids}")
|
||||
@SysLog(value = "确认导入数据", businessType = BusinessType.INSERT)
|
||||
@RequiresPermissions("store:import:save")
|
||||
public AjaxResult confimImport(@PathVariable Long[] ids)
|
||||
{
|
||||
return AjaxResult.success(storeImportService.confimImport(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ public interface StoreImportService extends IService<StoreImport> {
|
|||
PageResult pageList(StoreImportQuery storeImport, CommonParam commonParam);
|
||||
|
||||
|
||||
int confimImport(Long[] ids);
|
||||
int confimImport(List<StoreImportDTO> lists);
|
||||
|
||||
void saveList(List<StoreImportDTO> dtoList);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.chushang.inspection.terminal.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -12,7 +13,12 @@ import com.chushang.common.mybatis.page.CommonParam;
|
|||
import com.chushang.common.mybatis.utils.PageResult;
|
||||
import com.chushang.common.mybatis.utils.WrapperUtils;
|
||||
import com.chushang.inspection.project.dto.ProjectDTO;
|
||||
import com.chushang.inspection.project.dto.TaskQuery;
|
||||
import com.chushang.inspection.project.po.PollingTask;
|
||||
import com.chushang.inspection.project.po.WrkProject;
|
||||
import com.chushang.inspection.project.service.PollingTaskService;
|
||||
import com.chushang.inspection.project.vo.ConfigVO;
|
||||
import com.chushang.inspection.project.vo.TaskVO;
|
||||
import com.chushang.inspection.terminal.dto.StoreImportDTO;
|
||||
import com.chushang.inspection.terminal.mapper.StoreImportMapper;
|
||||
import com.chushang.inspection.terminal.mapper.StoreMapper;
|
||||
|
|
@ -28,6 +34,8 @@ import com.chushang.inspection.terminal.service.StoreImportService;
|
|||
import com.chushang.inspection.terminal.vo.StoreVO;
|
||||
import com.chushang.inspection.terminal.vo.TerminalVO;
|
||||
import com.chushang.inspection.utils.BeanCopyUtils;
|
||||
import com.chushang.inspection.work.po.WrkImg;
|
||||
import com.chushang.inspection.work.vo.WrkImgVO;
|
||||
import com.chushang.security.utils.SecurityUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -58,6 +66,9 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
|||
@Resource
|
||||
StoreMapper storeMapper;
|
||||
|
||||
@Resource
|
||||
PollingTaskService pollingTaskService;
|
||||
|
||||
@Override
|
||||
public PageResult pageList(StoreImportQuery query, CommonParam commonParam) {
|
||||
LambdaQueryWrapper<StoreImport> queryWrapper = WrapperUtils.builder(query, commonParam);
|
||||
|
|
@ -71,15 +82,25 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int confimImport(Long[] ids) {
|
||||
public int confimImport(List<StoreImportDTO> lists) {
|
||||
int i = 0;
|
||||
for (Long id : ids) {
|
||||
for (StoreImportDTO storeImportDTO : lists) {
|
||||
i++;
|
||||
StoreImport storeImport = getById(id);
|
||||
if (ObjectUtil.isEmpty(storeImport)) {
|
||||
throw new RuntimeException("导入失败");
|
||||
if (StringUtils.isBlank(storeImportDTO.getTaskName())) {
|
||||
throw new RuntimeException("任务名称不能为空");
|
||||
}
|
||||
|
||||
// 通过任务名称查询任务
|
||||
List<PollingTask> list = pollingTaskService.list(new LambdaQueryWrapper<PollingTask>().eq(PollingTask::getName, storeImportDTO.getTaskName()));
|
||||
if (CollectionUtil.isEmpty(list)){
|
||||
throw new RuntimeException("任务名称不存在");
|
||||
}
|
||||
PollingTask topTask = pollingTaskService.getTopTask(list.get(0).getId());
|
||||
StoreImport storeImport = BeanCopyUtils.copy(storeImportDTO, StoreImport.class);
|
||||
Store store = BeanCopyUtils.copy(storeImport, Store.class);
|
||||
store.setTaskId(topTask.getId());
|
||||
store.setDeptId(SecurityUtils.getDeptId());
|
||||
store.setLowerTaskId(list.get(0).getId());
|
||||
store.setStoreId(IdUtil.getSnowflake().nextId());
|
||||
storeMapper.insert(store);
|
||||
Terminal terminal = BeanCopyUtils.copy(storeImport, Terminal.class);
|
||||
|
|
@ -89,26 +110,10 @@ public class StoreImportServiceImpl extends ServiceImpl<StoreImportMapper, Store
|
|||
terminalIns.setTerminalId(terminal.getTerminalId());
|
||||
terminalIns.setStoreId(store.getStoreId());
|
||||
terminalInsMapper.insert(terminalIns);
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void saveList(List<StoreImportDTO> dtoList) {
|
||||
for (StoreImportDTO storeImportDTO : dtoList) {
|
||||
StoreImport copy = BeanCopyUtils.copy(storeImportDTO, StoreImport.class);
|
||||
copy.setDeptId(SecurityUtils.getDeptId());
|
||||
copy.setId(IdUtil.getSnowflake().nextId());
|
||||
try {
|
||||
save(copy);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("商户导入异常:{}", copy.getStoreName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue