|
|
|
@ -135,8 +135,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
} |
|
|
|
map.put("state", state); |
|
|
|
List<Depository> list = depositoryMapper.findDepositoryByCondition(map); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
Depository depository = list.get(i); |
|
|
|
for (Depository depository : list) { |
|
|
|
if (!depository.getAdminorg().isEmpty()) { |
|
|
|
Administration company = LinkInterfaceUtil.getCompany(ObjectFormatUtil.toInteger(depository.getAdminorg()), userByPort); |
|
|
|
depository.setAdminorgName(company.getName()); |
|
|
|
@ -255,6 +254,42 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
return depositoryMapper.changeStateToDeletedByIds(ids); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询当前仓库的最上层仓库 |
|
|
|
* |
|
|
|
* @param depositoryId 当前仓库 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Depository findTopDepositoryByDepository(Integer depositoryId) { |
|
|
|
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
if (Integer.compare(0, depositoryById.getParentId()) == 0) { |
|
|
|
// 如果当前仓库没有父级仓库
|
|
|
|
return depositoryById; |
|
|
|
} else { |
|
|
|
// 如果不是最高
|
|
|
|
|
|
|
|
// 获取所有仓库
|
|
|
|
List<Depository> depositoryAll = depositoryMapper.findDepositoryAll(); |
|
|
|
return findParentDepository(depositoryById, depositoryAll); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Depository findParentDepository(Depository depository, List<Depository> depositoryList) { |
|
|
|
for (Depository d : depositoryList |
|
|
|
) { |
|
|
|
if (Integer.compare(depository.getParentId(), d.getId()) == 0) { |
|
|
|
if(Integer.compare(0,d.getParentId()) == 0){ |
|
|
|
return d; |
|
|
|
}else{ |
|
|
|
return findParentDepository(d,depositoryList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算未删除仓库综合 |
|
|
|
* |
|
|
|
@ -428,99 +463,6 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于执行线程任务
|
|
|
|
class Task implements Callable<Object> { |
|
|
|
|
|
|
|
// 仓库
|
|
|
|
List<Integer> depositoryIdList; |
|
|
|
// 部门
|
|
|
|
String adminorg; |
|
|
|
// 当前登录用户
|
|
|
|
UserByPort userByPort; |
|
|
|
|
|
|
|
public Task(List<Integer> depositoryIdList,String adminorg,UserByPort userByPort){ |
|
|
|
this.depositoryIdList = depositoryIdList; |
|
|
|
this.adminorg = adminorg; |
|
|
|
this.userByPort = userByPort; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
/** |
|
|
|
* 获取当前仓库id对应的仓库 |
|
|
|
*/ |
|
|
|
List<Depository> depositories = depositoryMapper.selectDepositoryByIds(depositoryIdList); |
|
|
|
|
|
|
|
// 获取当前用户管理的仓库
|
|
|
|
List<RoleAndDepository> depositoryAndRole = roleMapper.findDepositoryAndRole(userByPort.getId()); |
|
|
|
|
|
|
|
|
|
|
|
// 定义树结构结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
// 定义线程池
|
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(depositories.size()); |
|
|
|
// 线程结果集
|
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
|
|
|
|
// 1.定义CompletionService用于获取结果
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
// 定义开启线程数
|
|
|
|
Integer openThreadSize = 0; |
|
|
|
for (int i = 0; i < depositories.size(); i++) { |
|
|
|
Depository depository = depositories.get(i); |
|
|
|
if("".equals(adminorg)||"361".equals(adminorg)){ // 如果不按部门分类或是仓储中心人员,则全部加载
|
|
|
|
Future<Object> submit = completionService.submit(new PlaceTask(depository)); |
|
|
|
futureList.add(submit); |
|
|
|
openThreadSize++; |
|
|
|
}else{ |
|
|
|
if(adminorg.equals(depository.getAdminorg()) || checkDidInDepositoryIdList(depository.getId(),depositoryAndRole)){ |
|
|
|
Future<Object> submit = completionService.submit(new PlaceTask(depository)); |
|
|
|
futureList.add(submit); |
|
|
|
openThreadSize++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < openThreadSize; i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
list.add(result); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于给仓库添加对应的库位 |
|
|
|
*/ |
|
|
|
class PlaceTask implements Callable<Object>{ |
|
|
|
|
|
|
|
Depository d; |
|
|
|
|
|
|
|
PlaceTask(Depository d){ |
|
|
|
this.d = d; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
// 获取当前仓库下的库位
|
|
|
|
List<Object> objectList = AddPlaceByDid(d); |
|
|
|
|
|
|
|
// 将其构造成对应的树形结构类型
|
|
|
|
Map<String, Object> map = InitTreeMenus2(d, objectList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 在仓库后添加库位信息
|
|
|
|
public List<Object> AddPlaceByDid(Depository d) { |
|
|
|
if (d != null) { |
|
|
|
@ -557,7 +499,6 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 构造树形组件数据模板
|
|
|
|
public Map<String, Object> InitTreeMenus2(Depository d, List<Object> children) { |
|
|
|
if (d != null) { |
|
|
|
@ -572,9 +513,9 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于构造树结构 |
|
|
|
* |
|
|
|
* @param list 树列表 |
|
|
|
* @param parentId 父级id |
|
|
|
* @return |
|
|
|
@ -599,6 +540,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断当前父级id是否在列表中 |
|
|
|
* |
|
|
|
* @param list |
|
|
|
* @param parentId |
|
|
|
* @return |
|
|
|
@ -616,6 +558,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于判断当前仓库是否是用户所管理的仓库 |
|
|
|
* |
|
|
|
* @param depositoryId 仓库id |
|
|
|
* @param list 用户管理仓库列表 |
|
|
|
* @return |
|
|
|
@ -630,7 +573,6 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前部门以及公共仓库 |
|
|
|
* |
|
|
|
@ -645,6 +587,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据仓库构造库位的树形选择框 |
|
|
|
* |
|
|
|
* @param depositoryId 仓库id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -711,6 +654,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取仓库对应的二维码 |
|
|
|
* |
|
|
|
* @param did |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -725,6 +669,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于添加仓库与二维码的对应关系 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -737,6 +682,7 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取每个仓库以及对应 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@ -744,10 +690,6 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
return depositoryMapper.getToDayInventoryByDNameTest(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean hasDepository(List<Depository> list, Depository o) { |
|
|
|
boolean flag = false; |
|
|
|
for (Depository depository : list) { |
|
|
|
@ -759,6 +701,96 @@ public class DepositoryServiceImpl implements DepositoryService { |
|
|
|
return flag; |
|
|
|
} |
|
|
|
|
|
|
|
// 用于执行线程任务
|
|
|
|
class Task implements Callable<Object> { |
|
|
|
|
|
|
|
// 仓库
|
|
|
|
List<Integer> depositoryIdList; |
|
|
|
// 部门
|
|
|
|
String adminorg; |
|
|
|
// 当前登录用户
|
|
|
|
UserByPort userByPort; |
|
|
|
|
|
|
|
public Task(List<Integer> depositoryIdList, String adminorg, UserByPort userByPort) { |
|
|
|
this.depositoryIdList = depositoryIdList; |
|
|
|
this.adminorg = adminorg; |
|
|
|
this.userByPort = userByPort; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
/** |
|
|
|
* 获取当前仓库id对应的仓库 |
|
|
|
*/ |
|
|
|
List<Depository> depositories = depositoryMapper.selectDepositoryByIds(depositoryIdList); |
|
|
|
|
|
|
|
// 获取当前用户管理的仓库
|
|
|
|
List<RoleAndDepository> depositoryAndRole = roleMapper.findDepositoryAndRole(userByPort.getId()); |
|
|
|
|
|
|
|
|
|
|
|
// 定义树结构结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
// 定义线程池
|
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(depositories.size()); |
|
|
|
// 线程结果集
|
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
|
|
|
|
// 1.定义CompletionService用于获取结果
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
// 定义开启线程数
|
|
|
|
Integer openThreadSize = 0; |
|
|
|
for (int i = 0; i < depositories.size(); i++) { |
|
|
|
Depository depository = depositories.get(i); |
|
|
|
if ("".equals(adminorg) || "361".equals(adminorg)) { // 如果不按部门分类或是仓储中心人员,则全部加载
|
|
|
|
Future<Object> submit = completionService.submit(new PlaceTask(depository)); |
|
|
|
futureList.add(submit); |
|
|
|
openThreadSize++; |
|
|
|
} else { |
|
|
|
if (adminorg.equals(depository.getAdminorg()) || checkDidInDepositoryIdList(depository.getId(), depositoryAndRole)) { |
|
|
|
Future<Object> submit = completionService.submit(new PlaceTask(depository)); |
|
|
|
futureList.add(submit); |
|
|
|
openThreadSize++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < openThreadSize; i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
list.add(result); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于给仓库添加对应的库位 |
|
|
|
*/ |
|
|
|
class PlaceTask implements Callable<Object> { |
|
|
|
|
|
|
|
Depository d; |
|
|
|
|
|
|
|
PlaceTask(Depository d) { |
|
|
|
this.d = d; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
// 获取当前仓库下的库位
|
|
|
|
List<Object> objectList = AddPlaceByDid(d); |
|
|
|
|
|
|
|
// 将其构造成对应的树形结构类型
|
|
|
|
Map<String, Object> map = InitTreeMenus2(d, objectList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|