|
|
|
@ -1950,128 +1950,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
return children; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形选择框 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> InitTreeMenus(String mname, String adminorg) { |
|
|
|
// 获取所有顶级类别
|
|
|
|
List<MaterialType> materialTypeNoParent = materialTypeMapper.findMaterialTypeNoParent(); |
|
|
|
// 开启对应数量的线程
|
|
|
|
int threadSize = materialTypeNoParent.size(); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
|
|
|
|
// 结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
MaterialType materialType = materialTypeNoParent.get(i); |
|
|
|
Future<Object> future = completionService.submit(new Task(materialType, mname, adminorg)); |
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3.获取结果
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
list.add(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形选择框(盘点) |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<Object> InitTreeMenus(String mname, String depositoryId, String placeId) { |
|
|
|
|
|
|
|
List<MaterialType> materialTypeNoParent = materialTypeMapper.findMaterialTypeNoParent(); |
|
|
|
// 开启对应数量的线程
|
|
|
|
int threadSize = materialTypeNoParent.size(); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
|
|
|
|
// 结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
|
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
MaterialType materialType = materialTypeNoParent.get(i); |
|
|
|
Future<Object> future = completionService.submit(new TaskForTaking(materialType, mname, depositoryId, placeId)); |
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
// 3.获取结果
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
list.add(result); |
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造树形选择框(普通) |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> InitTreeMenus(String mname) { |
|
|
|
List<MaterialType> materialTypeNoParent = materialTypeMapper.findMaterialTypeNoParent(); |
|
|
|
// 开启对应数量的线程
|
|
|
|
int threadSize = materialTypeNoParent.size(); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
|
|
|
|
// 结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
|
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
MaterialType materialType = materialTypeNoParent.get(i); |
|
|
|
Future<Object> future = completionService.submit(new Task(materialType, mname, "")); |
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
// 3.获取结果
|
|
|
|
for (int i = 0; i < materialTypeNoParent.size(); i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
list.add(result); |
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
// 构造树形组件数据模板
|
|
|
|
public Map<String, Object> InitTreeMenus(MaterialType mt, List<Object> children) { |
|
|
|
if (mt != null) { |
|
|
|
@ -2383,7 +2261,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 用于测试构造属性框
|
|
|
|
public List<Object> InitTreeMenus_Test() { |
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> wms_materialTree_result = redisPool.getRedisTemplateByDb(15).opsForList().range("wms_materialTree_result", 0, -1); |
|
|
|
if (wms_materialTree_result != null && wms_materialTree_result.size() != 0) { |
|
|
|
try { |
|
|
|
@ -2505,8 +2382,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 获取当前父类的子类
|
|
|
|
List<MaterialType> materialTypeByCondition = materialTypeMapper.findMaterialTypeByCondition(param); |
|
|
|
if (materialTypeByCondition.size() > 0 && (level == staticlevel)) { |
|
|
|
for (int i = 0; i < materialTypeByCondition.size(); i++) { |
|
|
|
MaterialType mt = materialTypeByCondition.get(i); |
|
|
|
for (MaterialType mt : materialTypeByCondition) { |
|
|
|
List<Object> childForMaterialTypeByParent_test = findChildForMaterialTypeByParent_Test(mt.getOldId(), level + 1, staticlevel); |
|
|
|
Map<String, Object> stringObjectMap = null; |
|
|
|
if (childForMaterialTypeByParent_test == null) { |
|
|
|
@ -2918,34 +2794,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class TaskForTaking implements Callable<Object> { |
|
|
|
|
|
|
|
MaterialType mt; |
|
|
|
String mname; |
|
|
|
String placeId; |
|
|
|
String depositoryId; |
|
|
|
|
|
|
|
public TaskForTaking(MaterialType mt, String mname, String depositoryId, String placeId) { |
|
|
|
this.mt = mt; |
|
|
|
this.mname = mname; |
|
|
|
this.placeId = placeId; |
|
|
|
this.depositoryId = depositoryId; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, depositoryId, placeId); |
|
|
|
Map<String, Object> stringObjectMap = new HashMap<>(); |
|
|
|
if (childForMaterialTypeByParent != null) { |
|
|
|
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent); |
|
|
|
} else { |
|
|
|
List<Object> materialByType = AddMaterialByType(mt, mname, depositoryId, placeId); |
|
|
|
stringObjectMap = InitTreeMenus(mt, materialByType); |
|
|
|
} |
|
|
|
return stringObjectMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 用于执行测试新算法
|
|
|
|
class TaskTest implements Callable<Object> { |
|
|
|
|
|
|
|
@ -2973,63 +2821,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
|
|
|
|
|
// 用于执行测试新算法
|
|
|
|
class TaskTest_New implements Callable<Object> { |
|
|
|
|
|
|
|
// 待处理的物料类型id列表
|
|
|
|
List<Long> materialTypeIdList; |
|
|
|
|
|
|
|
public TaskTest_New(List<Long> materialTypeByCondition) { |
|
|
|
this.materialTypeIdList = materialTypeByCondition; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
|
|
// 定义树结构结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
// 查询当前物料类型id列表中的物料类型
|
|
|
|
List<Material> materialByTypeIds = materialMapper.findMaterialByTypeIds(materialTypeIdList); |
|
|
|
// 查询当前物料类型所包含的物料
|
|
|
|
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList); |
|
|
|
|
|
|
|
// 定义线程集
|
|
|
|
int threadSize = materialTypeByOldIds.size(); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
|
|
|
|
// 定义线程结果集
|
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
|
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
for (int i = 0; i < materialTypeByOldIds.size(); i++) { |
|
|
|
// 获取当前物料类型
|
|
|
|
MaterialType mt = materialTypeByOldIds.get(i); |
|
|
|
// 开启对应线程
|
|
|
|
Future<Object> future = completionService.submit(new MtTaskTest_New(mt, materialByTypeIds)); |
|
|
|
// 添加到线程结果列表
|
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
// 3.获取结果
|
|
|
|
for (int i = 0; i < materialTypeIdList.size(); 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 MtTaskTest_New implements Callable<Object> { |
|
|
|
|