|
|
@ -49,6 +49,18 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
SplitUnitMapper splitUnitMapper; |
|
|
SplitUnitMapper splitUnitMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于深度拷贝列表 |
|
|
|
|
|
* |
|
|
|
|
|
* @param oldList |
|
|
|
|
|
* @param <T> |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public static <T> List<T> deepCopy(List<T> oldList) { |
|
|
|
|
|
List<T> newList = (List<T>) Arrays.asList(new Object[oldList.size()]); |
|
|
|
|
|
Collections.copy(newList, oldList); |
|
|
|
|
|
return newList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 增加一条库存记录 |
|
|
* 增加一条库存记录 |
|
|
@ -107,7 +119,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return materialMapper.insertMaterial(map); |
|
|
return materialMapper.insertMaterial(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 增加一条库存记录 |
|
|
* 增加一条库存记录 |
|
|
* |
|
|
* |
|
|
@ -164,7 +175,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return materialMapper.updateMaterial(map); |
|
|
return materialMapper.updateMaterial(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据id删除一条库存记录 |
|
|
* 根据id删除一条库存记录 |
|
|
* |
|
|
* |
|
|
@ -416,7 +426,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return inventoryByMid; |
|
|
return inventoryByMid; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据物料id获取其在对应仓库中的库存数 |
|
|
* 根据物料id获取其在对应仓库中的库存数 |
|
|
* |
|
|
* |
|
|
@ -570,7 +579,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return materialMapper.updateStateByParam(map); |
|
|
return materialMapper.updateStateByParam(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 对查出来的库存记录进行包装,包装成前端需要的数据 |
|
|
* 对查出来的库存记录进行包装,包装成前端需要的数据 |
|
|
* |
|
|
* |
|
|
@ -636,7 +644,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(m.getId(), m.getDepositoryId()); |
|
|
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(m.getId(), m.getDepositoryId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Integer> splitInventoryForUnit = new HashMap<>(); |
|
|
Map<String, Integer> splitInventoryForUnit = new HashMap<>(); |
|
|
|
|
|
|
|
|
// 获取拆单信息对应库存
|
|
|
// 获取拆单信息对应库存
|
|
|
StringBuilder showQuantity = new StringBuilder(); |
|
|
StringBuilder showQuantity = new StringBuilder(); |
|
|
@ -646,7 +654,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
if (Integer.compare(m.getQuantity(), 0) != 0) { |
|
|
if (Integer.compare(m.getQuantity(), 0) != 0) { |
|
|
showQuantity.append(m.getUnit()).append(":").append(m.getQuantity()).append(" "); |
|
|
showQuantity.append(m.getUnit()).append(":").append(m.getQuantity()).append(" "); |
|
|
} |
|
|
} |
|
|
for (PlaceP place: |
|
|
for (PlaceP place : |
|
|
placeByMidAndDid) { |
|
|
placeByMidAndDid) { |
|
|
// 获取当前具体数据
|
|
|
// 获取当前具体数据
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(place.getId(), m.getId()); |
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(place.getId(), m.getId()); |
|
|
@ -657,14 +665,14 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
for (SplitInventory splitInventory : splitInventoryList) { |
|
|
for (SplitInventory splitInventory : splitInventoryList) { |
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventory.getSid()); |
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventory.getSid()); |
|
|
if (Integer.compare(splitInventory.getSaveQuantity(), 0) != 0) { |
|
|
if (Integer.compare(splitInventory.getSaveQuantity(), 0) != 0) { |
|
|
if(splitInventoryForUnit.containsKey(splitInfo.getNewUnit())){ |
|
|
if (splitInventoryForUnit.containsKey(splitInfo.getNewUnit())) { |
|
|
// 如果当前存在该拆单类型的记录
|
|
|
// 如果当前存在该拆单类型的记录
|
|
|
|
|
|
|
|
|
// 更新当前类型数据
|
|
|
// 更新当前类型数据
|
|
|
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventoryForUnit.get(splitInfo.getNewUnit())+splitInventory.getSaveQuantity()); |
|
|
splitInventoryForUnit.put(splitInfo.getNewUnit(), splitInventoryForUnit.get(splitInfo.getNewUnit()) + splitInventory.getSaveQuantity()); |
|
|
}else{ |
|
|
} else { |
|
|
// 如果不存在,则新增
|
|
|
// 如果不存在,则新增
|
|
|
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventory.getSaveQuantity()); |
|
|
splitInventoryForUnit.put(splitInfo.getNewUnit(), splitInventory.getSaveQuantity()); |
|
|
} |
|
|
} |
|
|
// 计算拆单后的单价
|
|
|
// 计算拆单后的单价
|
|
|
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity()); |
|
|
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity()); |
|
|
@ -678,14 +686,13 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 设置新总额
|
|
|
// 设置新总额
|
|
|
m.setAmounts(m.getAmounts() + amounts); |
|
|
m.setAmounts(m.getAmounts() + amounts); |
|
|
// 获取当前各拆单信息对应的库存
|
|
|
// 获取当前各拆单信息对应的库存
|
|
|
splitInventoryForUnit.put(inventory.getUnit(),inventory.getQuantity()); |
|
|
splitInventoryForUnit.put(inventory.getUnit(), inventory.getQuantity()); |
|
|
m.setShowQuantity(splitInventoryForUnit); |
|
|
m.setShowQuantity(splitInventoryForUnit); |
|
|
result.add(m); |
|
|
result.add(m); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 对查出来的物料记录进行包装,包装成前端需要的数据 |
|
|
* 对查出来的物料记录进行包装,包装成前端需要的数据 |
|
|
* |
|
|
* |
|
|
@ -1123,7 +1130,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 设置当前树结构为打开状态 |
|
|
* 设置当前树结构为打开状态 |
|
|
* |
|
|
* |
|
|
@ -1192,7 +1198,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于判断当前类型是几级子类 |
|
|
* 用于判断当前类型是几级子类 |
|
|
* |
|
|
* |
|
|
@ -1262,12 +1267,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<Object> InitMaterialTree_New() { |
|
|
|
|
|
List<Object> objectList = buildTree_New(InitTree_Test_New(), Long.valueOf(0)); |
|
|
|
|
|
return objectList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于修改库位中的物料 |
|
|
* 用于修改库位中的物料 |
|
|
* |
|
|
* |
|
|
@ -1346,7 +1345,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于真实关闭打开的树 |
|
|
* 用于真实关闭打开的树 |
|
|
* |
|
|
* |
|
|
@ -1388,7 +1386,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return ja; |
|
|
return ja; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 重构树结构 |
|
|
* 重构树结构 |
|
|
* |
|
|
* |
|
|
@ -1487,7 +1484,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return children; |
|
|
return children; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 构造树形选择框 |
|
|
* 构造树形选择框 |
|
|
* |
|
|
* |
|
|
@ -1604,61 +1600,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用于执行线程任务(用于构造物料树形)
|
|
|
|
|
|
class Task implements Callable<Object> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; |
|
|
|
|
|
String mname; |
|
|
|
|
|
String adminorg; |
|
|
|
|
|
|
|
|
|
|
|
public Task(MaterialType mt, String mname, String adminorg) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.mname = mname; |
|
|
|
|
|
this.adminorg = adminorg; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, adminorg); |
|
|
|
|
|
Map<String, Object> stringObjectMap = new HashMap<>(); |
|
|
|
|
|
if (childForMaterialTypeByParent != null) { |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<Object> materialByType = AddMaterialByType(mt, mname, adminorg); |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, materialByType); |
|
|
|
|
|
} |
|
|
|
|
|
return stringObjectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 构造树形组件数据模板
|
|
|
// 构造树形组件数据模板
|
|
|
public Map<String, Object> InitTreeMenus(MaterialType mt, List<Object> children) { |
|
|
public Map<String, Object> InitTreeMenus(MaterialType mt, List<Object> children) { |
|
|
if (mt != null) { |
|
|
if (mt != null) { |
|
|
@ -1672,7 +1613,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构造树形组件数据模板
|
|
|
// 构造树形组件数据模板
|
|
|
public Map<String, Object> InitTreeMenusTest(MaterialType mt, List<Object> children) { |
|
|
public Map<String, Object> InitTreeMenusTest(MaterialType mt, List<Object> children) { |
|
|
if (mt != null) { |
|
|
if (mt != null) { |
|
|
@ -1939,7 +1879,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据类别id获取子类(盘点专用)
|
|
|
// 根据类别id获取子类(盘点专用)
|
|
|
public List<Object> findChildForMaterialTypeByParent(Long id, String mname, String depositoryId, String placeId) { |
|
|
public List<Object> findChildForMaterialTypeByParent(Long id, String mname, String depositoryId, String placeId) { |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
@ -1969,7 +1908,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于测试构造属性框
|
|
|
// 用于测试构造属性框
|
|
|
public List<Object> InitTreeMenus_Test() { |
|
|
public List<Object> InitTreeMenus_Test() { |
|
|
List<Object> list = new ArrayList<>(); |
|
|
List<Object> list = new ArrayList<>(); |
|
|
@ -2025,34 +1963,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用于执行测试新算法
|
|
|
|
|
|
class TaskTest implements Callable<Object> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; |
|
|
|
|
|
Integer level; |
|
|
|
|
|
Integer staticLevel; |
|
|
|
|
|
|
|
|
|
|
|
public TaskTest(MaterialType mt, Integer level, Integer staticLevel) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.level = level; |
|
|
|
|
|
this.staticLevel = staticLevel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent_Test(mt.getOldId(), 1, 1); |
|
|
|
|
|
Map<String, Object> stringObjectMap = new HashMap<>(); |
|
|
|
|
|
if (childForMaterialTypeByParent != null) { |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<Object> materialByType = AddMaterialByType(mt, "", ""); |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, materialByType); |
|
|
|
|
|
} |
|
|
|
|
|
return stringObjectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据id获取子类(只获取类别)
|
|
|
// 根据id获取子类(只获取类别)
|
|
|
public List<Object> findChildForMaterialTypeByParent_OnlyType(Long Oldid) { |
|
|
public List<Object> findChildForMaterialTypeByParent_OnlyType(Long Oldid) { |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
@ -2073,7 +1983,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据id获取子类
|
|
|
// 根据id获取子类
|
|
|
public List<Object> findChildForMaterialTypeByParent_Test(Long Oldid, int level, int staticlevel) { |
|
|
public List<Object> findChildForMaterialTypeByParent_Test(Long Oldid, int level, int staticlevel) { |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
@ -2103,20 +2012,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于深度拷贝列表 |
|
|
|
|
|
* |
|
|
|
|
|
* @param oldList |
|
|
|
|
|
* @param <T> |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public static <T> List<T> deepCopy(List<T> oldList) { |
|
|
|
|
|
List<T> newList = (List<T>) Arrays.asList(new Object[oldList.size()]); |
|
|
|
|
|
Collections.copy(newList, oldList); |
|
|
|
|
|
return newList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于构造物料树结构 |
|
|
* 用于构造物料树结构 |
|
|
* |
|
|
* |
|
|
@ -2186,91 +2081,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用于执行测试新算法
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
// 定义线程集
|
|
|
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(materialTypeByOldIds.size()); |
|
|
|
|
|
// 定义线程结果集
|
|
|
|
|
|
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> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; // 物料类型
|
|
|
|
|
|
List<Material> materiaList; // 物料列表
|
|
|
|
|
|
|
|
|
|
|
|
public MtTaskTest_New(MaterialType mt, List<Material> materiaList) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.materiaList = materiaList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
// 开启对应数量的线程
|
|
|
|
|
|
List<Material> materialList = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < materiaList.size(); i++) { |
|
|
|
|
|
Material material = materiaList.get(i); |
|
|
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
|
|
|
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
|
|
|
materialList.add(material); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 将物料打包成树结构对应结果
|
|
|
|
|
|
List<Object> objectList = AddMaterialByType_New(materialList); |
|
|
|
|
|
// 封装成对应的结构
|
|
|
|
|
|
Map<String, Object> objectMap = InitTreeMenus_New(mt, objectList); |
|
|
|
|
|
return objectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 构造树形组件数据模板
|
|
|
// 构造树形组件数据模板
|
|
|
public Map<String, Object> InitTreeMenus_New(MaterialType mt, List<Object> children) { |
|
|
public Map<String, Object> InitTreeMenus_New(MaterialType mt, List<Object> children) { |
|
|
if (mt != null) { |
|
|
if (mt != null) { |
|
|
@ -2329,23 +2139,22 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于构造物料树结构(通过物料名称搜索) |
|
|
* 用于构造物料树结构(通过物料名称搜索) |
|
|
* |
|
|
* |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public List<Object> InitTreeForSelectName(String mname, String type) { |
|
|
public List<Object> InitTreeForSelectName(String mname, String type,Map<String,Object> map) { |
|
|
// 获取所有物料类型
|
|
|
// 获取所有物料类型
|
|
|
List<MaterialType> materialTypeAll = materialTypeMapper.findMaterialTypeAll(); |
|
|
List<MaterialType> materialTypeAll = materialTypeMapper.findMaterialTypeAll(); |
|
|
// 物料总数
|
|
|
// 物料总数
|
|
|
Integer totalVal = materialTypeAll.size(); |
|
|
int totalVal = materialTypeAll.size(); |
|
|
|
|
|
|
|
|
// 定义分页数量
|
|
|
// 定义分页数量
|
|
|
double size = 100.0; |
|
|
double size = 100.0; |
|
|
|
|
|
|
|
|
// 定义线程数
|
|
|
// 定义线程数
|
|
|
Integer threadSize = (int) Math.ceil(totalVal / size); |
|
|
int threadSize = (int) Math.ceil(totalVal / size); |
|
|
|
|
|
|
|
|
// 开启对应数量的线程
|
|
|
// 开启对应数量的线程
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(threadSize); |
|
|
ExecutorService exs = Executors.newFixedThreadPool(threadSize); |
|
|
@ -2358,12 +2167,22 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
// 物料类型id列表
|
|
|
// 物料类型id列表
|
|
|
List<Long> materialTypeList = new ArrayList<>(); |
|
|
List<Long> materialTypeList = new ArrayList<>(); |
|
|
|
|
|
// 用于标志是否为库存盘点
|
|
|
|
|
|
boolean flagForStock = false; |
|
|
|
|
|
if("3".equals(type)){ |
|
|
|
|
|
// 如果是库存盘点
|
|
|
|
|
|
flagForStock = true; |
|
|
|
|
|
} |
|
|
for (int i = 0; i < materialTypeAll.size(); i++) { |
|
|
for (int i = 0; i < materialTypeAll.size(); i++) { |
|
|
// 获取当前类型
|
|
|
// 获取当前类型
|
|
|
MaterialType materialType = materialTypeAll.get(i); |
|
|
MaterialType materialType = materialTypeAll.get(i); |
|
|
if (((i + 1) % 100) == 0) { // 如果有100个开启线程进行处理
|
|
|
if (((i + 1) % 100) == 0) { // 如果有100个开启线程进行处理
|
|
|
materialTypeList.add(materialType.getOldId()); |
|
|
materialTypeList.add(materialType.getOldId()); |
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type)); |
|
|
TaskTestForSelectMname taskTestForSelectMname = new TaskTestForSelectMname(materialTypeList, mname, type); |
|
|
|
|
|
if(flagForStock){ |
|
|
|
|
|
taskTestForSelectMname.setMap(map); |
|
|
|
|
|
} |
|
|
|
|
|
Future<Object> future = completionService.submit(taskTestForSelectMname); |
|
|
futureList.add(future); // 添加到结果集
|
|
|
futureList.add(future); // 添加到结果集
|
|
|
materialTypeList = new ArrayList<>(); // 情况列表
|
|
|
materialTypeList = new ArrayList<>(); // 情况列表
|
|
|
} else { |
|
|
} else { |
|
|
@ -2374,7 +2193,11 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
if (materialTypeList.size() > 0) { |
|
|
if (materialTypeList.size() > 0) { |
|
|
// 如果有剩余,开启线程进行处理
|
|
|
// 如果有剩余,开启线程进行处理
|
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type)); |
|
|
TaskTestForSelectMname taskTestForSelectMname = new TaskTestForSelectMname(materialTypeList, mname, type); |
|
|
|
|
|
if(flagForStock){ |
|
|
|
|
|
taskTestForSelectMname.setMap(map); |
|
|
|
|
|
} |
|
|
|
|
|
Future<Object> future = completionService.submit(taskTestForSelectMname); |
|
|
futureList.add(future); |
|
|
futureList.add(future); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -2394,39 +2217,309 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return buildTreeForSelectName(list); |
|
|
return buildTreeForSelectName(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
// 构造树形组件数据模板(通过物料名称搜索)
|
|
|
class TaskTestForSelectMname implements Callable<Object> { |
|
|
public Map<String, Object> InitTreeMenusForSelectName(MaterialType mt, List<Object> children) { |
|
|
|
|
|
if (mt != null) { |
|
|
// 待处理的物料类型id列表
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
List<Long> materialTypeIdList; |
|
|
map.put("title", mt.getTname()); |
|
|
String mname; |
|
|
map.put("id", mt.getOldId()); |
|
|
// 1入库2出库3盘点
|
|
|
map.put("parentId", mt.getParentId()); |
|
|
String type; |
|
|
map.put("children", children); |
|
|
|
|
|
return map; |
|
|
public TaskTestForSelectMname(List<Long> materialTypeByCondition, String mname, String type) { |
|
|
} else { |
|
|
this.materialTypeIdList = materialTypeByCondition; |
|
|
return null; |
|
|
this.mname = mname; |
|
|
} |
|
|
this.type = type; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
// 在类别后添加物料名称(通过物料名称搜索)
|
|
|
public Object call() throws Exception { |
|
|
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList, List<Inventory> inventoryList) { |
|
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
// 定义树结构结果集
|
|
|
if (materialList != null) { |
|
|
List<Object> list = new ArrayList<>(); |
|
|
for (Material material : materialList) { |
|
|
// 查询当前物料类型id列表中的物料类型
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
Map<String, Object> paramForMnameAndMtid = new HashMap<>(); |
|
|
String version = material.getVersion(); |
|
|
paramForMnameAndMtid.put("list", materialTypeIdList); |
|
|
if (version == null) { |
|
|
paramForMnameAndMtid.put("mname", mname); |
|
|
version = ""; |
|
|
List<Material> materialByTypeIds = new ArrayList<>(); |
|
|
} |
|
|
List<Inventory> inventoryByTypeIdsAndMname = new ArrayList<>(); |
|
|
String title = ""; |
|
|
if ("1".equals(type)) { |
|
|
title = material.getMname() + ",规格型号: " + version; |
|
|
materialByTypeIds = materialMapper.findMaterialByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
map.put("title", title); |
|
|
|
|
|
map.put("id", material.getId()); |
|
|
|
|
|
result.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (inventoryList != null) { |
|
|
|
|
|
for (Inventory inventory : inventoryList) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
String version = inventory.getVersion(); |
|
|
|
|
|
if (version == null) { |
|
|
|
|
|
version = ""; |
|
|
|
|
|
} |
|
|
|
|
|
StringBuilder title = new StringBuilder(); |
|
|
|
|
|
title = new StringBuilder(inventory.getMname() + ",规格型号: " + version + ",库存数量:" + inventory.getUnit() + ":" + inventory.getQuantity()); |
|
|
|
|
|
// 获取对应拆单库存处理记录
|
|
|
|
|
|
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
|
|
if (splitInventoryList.size() > 0) { |
|
|
|
|
|
// 如果不为空
|
|
|
|
|
|
|
|
|
|
|
|
// 获取对应拆单信息
|
|
|
|
|
|
for (SplitInventory splitInventory : |
|
|
|
|
|
splitInventoryList) { |
|
|
|
|
|
|
|
|
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventory.getSid()); |
|
|
|
|
|
title.append(",").append(splitInfoById.getNewUnit()).append(":").append(splitInventory.getSaveQuantity()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
map.put("title", title.toString()); |
|
|
|
|
|
map.put("id", inventory.getId()); |
|
|
|
|
|
result.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于构造树结构(通过物料名称搜索) |
|
|
|
|
|
* |
|
|
|
|
|
* @param list 树列表 |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Object> buildTreeForSelectName(List<Object> list) { |
|
|
|
|
|
// 定义树结构
|
|
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
// 构造为jsonObject类
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject((Map<String, Object>) list.get(i)); |
|
|
|
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
|
|
|
if (children.size() > 0) { |
|
|
|
|
|
result.add(jsonObject); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于执行线程任务(用于构造物料树形)
|
|
|
|
|
|
class Task implements Callable<Object> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; |
|
|
|
|
|
String mname; |
|
|
|
|
|
String adminorg; |
|
|
|
|
|
|
|
|
|
|
|
public Task(MaterialType mt, String mname, String adminorg) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.mname = mname; |
|
|
|
|
|
this.adminorg = adminorg; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, adminorg); |
|
|
|
|
|
Map<String, Object> stringObjectMap = new HashMap<>(); |
|
|
|
|
|
if (childForMaterialTypeByParent != null) { |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<Object> materialByType = AddMaterialByType(mt, mname, adminorg); |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, materialByType); |
|
|
|
|
|
} |
|
|
|
|
|
return stringObjectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; |
|
|
|
|
|
Integer level; |
|
|
|
|
|
Integer staticLevel; |
|
|
|
|
|
|
|
|
|
|
|
public TaskTest(MaterialType mt, Integer level, Integer staticLevel) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.level = level; |
|
|
|
|
|
this.staticLevel = staticLevel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent_Test(mt.getOldId(), 1, 1); |
|
|
|
|
|
Map<String, Object> stringObjectMap = new HashMap<>(); |
|
|
|
|
|
if (childForMaterialTypeByParent != null) { |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<Object> materialByType = AddMaterialByType(mt, "", ""); |
|
|
|
|
|
stringObjectMap = InitTreeMenus(mt, materialByType); |
|
|
|
|
|
} |
|
|
|
|
|
return stringObjectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
|
|
|
|
|
|
|
|
|
// 用于执行测试新算法
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
// 定义线程集
|
|
|
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(materialTypeByOldIds.size()); |
|
|
|
|
|
// 定义线程结果集
|
|
|
|
|
|
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> { |
|
|
|
|
|
|
|
|
|
|
|
MaterialType mt; // 物料类型
|
|
|
|
|
|
List<Material> materiaList; // 物料列表
|
|
|
|
|
|
|
|
|
|
|
|
public MtTaskTest_New(MaterialType mt, List<Material> materiaList) { |
|
|
|
|
|
this.mt = mt; |
|
|
|
|
|
this.materiaList = materiaList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
// 开启对应数量的线程
|
|
|
|
|
|
List<Material> materialList = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < materiaList.size(); i++) { |
|
|
|
|
|
Material material = materiaList.get(i); |
|
|
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
|
|
|
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
|
|
|
materialList.add(material); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 将物料打包成树结构对应结果
|
|
|
|
|
|
List<Object> objectList = AddMaterialByType_New(materialList); |
|
|
|
|
|
// 封装成对应的结构
|
|
|
|
|
|
Map<String, Object> objectMap = InitTreeMenus_New(mt, objectList); |
|
|
|
|
|
return objectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
|
|
|
class TaskTestForSelectMname implements Callable<Object> { |
|
|
|
|
|
|
|
|
|
|
|
// 待处理的物料类型id列表
|
|
|
|
|
|
List<Long> materialTypeIdList; |
|
|
|
|
|
String mname; |
|
|
|
|
|
// 1入库2出库3盘点
|
|
|
|
|
|
String type; |
|
|
|
|
|
// 相关使用的数据
|
|
|
|
|
|
Map<String,Object> map; |
|
|
|
|
|
|
|
|
|
|
|
public void setMap(Map<String, Object> map) { |
|
|
|
|
|
this.map = map; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TaskTestForSelectMname(List<Long> materialTypeByCondition, String mname, String type) { |
|
|
|
|
|
this.materialTypeIdList = materialTypeByCondition; |
|
|
|
|
|
this.mname = mname; |
|
|
|
|
|
this.type = type; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
// 定义树结构结果集
|
|
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
|
|
// 查询当前物料类型id列表中的物料类型
|
|
|
|
|
|
Map<String, Object> paramForMnameAndMtid = new HashMap<>(); |
|
|
|
|
|
paramForMnameAndMtid.put("list", materialTypeIdList); |
|
|
|
|
|
paramForMnameAndMtid.put("mname", mname); |
|
|
|
|
|
List<Material> materialByTypeIds = new ArrayList<>(); |
|
|
|
|
|
List<Inventory> inventoryByTypeIdsAndMname = new ArrayList<>(); |
|
|
|
|
|
if ("1".equals(type)) { |
|
|
|
|
|
// 如果是入库
|
|
|
|
|
|
materialByTypeIds = materialMapper.findMaterialByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
} else if ("2".equals(type)) { |
|
|
} else if ("2".equals(type)) { |
|
|
|
|
|
// 如果是出库
|
|
|
inventoryByTypeIdsAndMname = materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
inventoryByTypeIdsAndMname = materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
|
|
|
}else if("3".equals(type)){ |
|
|
|
|
|
// 如果是盘点
|
|
|
|
|
|
List<Inventory> inventoryList = materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
|
|
|
|
|
|
|
|
|
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); |
|
|
|
|
|
// 查询当前存在于当前库位的物料
|
|
|
|
|
|
for (Inventory inventory: |
|
|
|
|
|
inventoryList) { |
|
|
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, inventory.getId()); |
|
|
|
|
|
if(placeAndMaterialByMidAndPid != null){ |
|
|
|
|
|
inventoryByTypeIdsAndMname.add(inventory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
// 查询当前物料类型所包含的物料
|
|
|
// 查询当前物料类型所包含的物料
|
|
|
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList); |
|
|
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList); |
|
|
|
|
|
|
|
|
@ -2446,7 +2539,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 添加到线程结果列表
|
|
|
// 添加到线程结果列表
|
|
|
futureList.add(future); |
|
|
futureList.add(future); |
|
|
} |
|
|
} |
|
|
} else if ("2".equals(type)) { |
|
|
} else if ("2".equals(type) || "3".equals(type)) { |
|
|
for (MaterialType mt : materialTypeByOldIds) { |
|
|
for (MaterialType mt : materialTypeByOldIds) { |
|
|
// 获取当前物料类型
|
|
|
// 获取当前物料类型
|
|
|
// 开启对应线程
|
|
|
// 开启对应线程
|
|
|
@ -2475,8 +2568,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
|
|
|
|
|
|
|
|
|
class MtTaskTestForSelectMname implements Callable<Object> { |
|
|
class MtTaskTestForSelectMname implements Callable<Object> { |
|
|
|
|
|
|
|
|
MaterialType mt; // 物料类型
|
|
|
MaterialType mt; // 物料类型
|
|
|
@ -2505,17 +2596,15 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 将物料打包成树结构对应结果
|
|
|
// 将物料打包成树结构对应结果
|
|
|
List<Object> objectList = new ArrayList<>(); |
|
|
List<Object> objectList = new ArrayList<>(); |
|
|
if ("1".equals(type)) { |
|
|
if ("1".equals(type)) { |
|
|
for (int i = 0; i < materiaList.size(); i++) { |
|
|
for (Material material : materiaList) { |
|
|
Material material = materiaList.get(i); |
|
|
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
materialList.add(material); |
|
|
materialList.add(material); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
objectList = AddMaterialByTypeForSelectMname(materialList, null); |
|
|
objectList = AddMaterialByTypeForSelectMname(materialList, null); |
|
|
} else if ("2".equals(type)) { |
|
|
} else if ("2".equals(type) || "3".equals(type)) { |
|
|
for (int i = 0; i < inventorys.size(); i++) { |
|
|
for (Inventory inventory : inventorys) { |
|
|
Inventory inventory = inventorys.get(i); |
|
|
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
if (Long.compare(inventory.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
if (Long.compare(inventory.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
inventoryList.add(inventory); |
|
|
inventoryList.add(inventory); |
|
|
@ -2525,90 +2614,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 封装成对应的结构
|
|
|
// 封装成对应的结构
|
|
|
Map<String, Object> objectMap = InitTreeMenusForSelectName(mt, objectList); |
|
|
return InitTreeMenusForSelectName(mt, objectList); |
|
|
return objectMap; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 构造树形组件数据模板(通过物料名称搜索)
|
|
|
|
|
|
public Map<String, Object> InitTreeMenusForSelectName(MaterialType mt, List<Object> children) { |
|
|
|
|
|
if (mt != null) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
map.put("title", mt.getTname()); |
|
|
|
|
|
map.put("id", mt.getOldId()); |
|
|
|
|
|
map.put("parentId", mt.getParentId()); |
|
|
|
|
|
map.put("children", children); |
|
|
|
|
|
return map; |
|
|
|
|
|
} else { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 在类别后添加物料名称(通过物料名称搜索)
|
|
|
|
|
|
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList, List<Inventory> inventoryList) { |
|
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
|
if (materialList != null) { |
|
|
|
|
|
for (Material material : materialList) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
String version = material.getVersion(); |
|
|
|
|
|
if (version == null) { |
|
|
|
|
|
version = ""; |
|
|
|
|
|
} |
|
|
|
|
|
String title = ""; |
|
|
|
|
|
title = material.getMname() + ",规格型号: " + version; |
|
|
|
|
|
map.put("title", title); |
|
|
|
|
|
map.put("id", material.getId()); |
|
|
|
|
|
result.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (inventoryList != null) { |
|
|
|
|
|
for (Inventory inventory : inventoryList) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
String version = inventory.getVersion(); |
|
|
|
|
|
if (version == null) { |
|
|
|
|
|
version = ""; |
|
|
|
|
|
} |
|
|
|
|
|
StringBuilder title = new StringBuilder(); |
|
|
|
|
|
title = new StringBuilder(inventory.getMname() + ",规格型号: " + version + ",库存数量:" + inventory.getUnit() + ":" + inventory.getQuantity()); |
|
|
|
|
|
// 获取对应拆单库存处理记录
|
|
|
|
|
|
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
|
|
if (splitInventoryList.size() > 0) { |
|
|
|
|
|
// 如果不为空
|
|
|
|
|
|
|
|
|
|
|
|
// 获取对应拆单信息
|
|
|
|
|
|
for (SplitInventory splitInventory : |
|
|
|
|
|
splitInventoryList) { |
|
|
|
|
|
|
|
|
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventory.getSid()); |
|
|
|
|
|
title.append(",").append(splitInfoById.getNewUnit()).append(":").append(splitInventory.getSaveQuantity()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
map.put("title", title.toString()); |
|
|
|
|
|
map.put("id", inventory.getId()); |
|
|
|
|
|
result.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于构造树结构(通过物料名称搜索) |
|
|
|
|
|
* |
|
|
|
|
|
* @param list 树列表 |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Object> buildTreeForSelectName(List<Object> list) { |
|
|
|
|
|
// 定义树结构
|
|
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
// 构造为jsonObject类
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject((Map<String, Object>) list.get(i)); |
|
|
|
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
|
|
|
if (children.size() > 0) { |
|
|
|
|
|
result.add(jsonObject); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|