|
|
|
@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
|
import com.dreamchaser.depository_manage.mapper.DepositoryMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.MaterialMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.MaterialTypeMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.QrCodeMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.*; |
|
|
|
import com.dreamchaser.depository_manage.pojo.InventoryP; |
|
|
|
import com.dreamchaser.depository_manage.pojo.MaterialP; |
|
|
|
import com.dreamchaser.depository_manage.pojo.PlaceP; |
|
|
|
@ -16,6 +13,7 @@ import com.dreamchaser.depository_manage.service.PlaceService; |
|
|
|
import com.dreamchaser.depository_manage.service.RoleService; |
|
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
|
import lombok.Data; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -48,6 +46,9 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
@Autowired |
|
|
|
RedisTemplate<String, String> redisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
SplitUnitMapper splitUnitMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 增加一条库存记录 |
|
|
|
@ -141,9 +142,9 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
int shelfLife = 0; |
|
|
|
if (map.containsKey("shelfLife")) { |
|
|
|
String life = map.get("shelfLife").toString(); |
|
|
|
if(!("".equals(life))){ |
|
|
|
if (!("".equals(life))) { |
|
|
|
shelfLife = ObjectFormatUtil.toInteger(life); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
shelfLife = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -153,7 +154,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("2" + shelfLife)); |
|
|
|
} else if ("year".equals(dateType) && shelfLife != -1) { |
|
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("1" + shelfLife)); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
map.remove("shelfLife"); |
|
|
|
} |
|
|
|
if (map.containsKey("producedDate")) { |
|
|
|
@ -193,10 +194,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
map.put("begin", (page - 1) * size); |
|
|
|
} |
|
|
|
Object state = 1; |
|
|
|
if(map.containsKey("state")){ |
|
|
|
if (map.containsKey("state")) { |
|
|
|
state = map.get("state"); |
|
|
|
} |
|
|
|
map.put("state",state); |
|
|
|
map.put("state", state); |
|
|
|
List<Material> list = materialMapper.findMaterialByCondition(map); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
list.get(i).setPrice(list.get(i).getPrice() / 100); |
|
|
|
@ -226,6 +227,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料名与物料规格型号查询对应的物料 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -276,6 +278,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询符合条件的库存 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -339,6 +342,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询物料总数 |
|
|
|
* |
|
|
|
* @param map 查询条件 |
|
|
|
* @return 当前条件下的总数 |
|
|
|
*/ |
|
|
|
@ -380,6 +384,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据库存id查询库存信息 |
|
|
|
* |
|
|
|
* @param id 库存id |
|
|
|
* @return 库存信息 |
|
|
|
*/ |
|
|
|
@ -395,6 +400,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料id获取对应库存信息 |
|
|
|
* |
|
|
|
* @param mid 待查询物料id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -413,6 +419,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料id获取其在对应仓库中的库存数 |
|
|
|
* |
|
|
|
* @param mid 物料id |
|
|
|
* @param depositoryList 待查询的仓库 |
|
|
|
* @return |
|
|
|
@ -422,15 +429,15 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 用于存储各仓库的库存
|
|
|
|
List<Integer> result = new ArrayList<>(); |
|
|
|
//
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("mid",mid); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("mid", mid); |
|
|
|
for (int i = 0; i < depositoryList.size(); i++) { |
|
|
|
Depository depository = depositoryList.get(i); |
|
|
|
map.put("did",depository.getId()); |
|
|
|
map.put("did", depository.getId()); |
|
|
|
Inventory inventory = materialMapper.findInventoryByMidAndDid(map); |
|
|
|
if(inventory!=null) { |
|
|
|
if (inventory != null) { |
|
|
|
result.add(inventory.getQuantity()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
result.add(0); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -439,6 +446,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据id查询库存信息 |
|
|
|
* |
|
|
|
* @param id 库存id |
|
|
|
* @return 库存信息 |
|
|
|
*/ |
|
|
|
@ -505,10 +513,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
@Override |
|
|
|
public Integer findCountByCondition(Map<String, Object> map) { |
|
|
|
Object state = 1; |
|
|
|
if(map.containsKey("state")){ |
|
|
|
if (map.containsKey("state")) { |
|
|
|
state = map.get("state"); |
|
|
|
} |
|
|
|
map.put("state",state); |
|
|
|
map.put("state", state); |
|
|
|
return materialMapper.findCountByCondition(map); |
|
|
|
} |
|
|
|
|
|
|
|
@ -619,6 +627,21 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
m.setTypeName(materialTypeByOldId.getTname()); |
|
|
|
m.setTypeId(materialTypeByOldId.getOldId()); |
|
|
|
m.setWarningCount(warningCount); |
|
|
|
// 获取当前是否存在拆单处理记录
|
|
|
|
SplitInventory splitInventoryByIid = splitUnitMapper.findSplitInventoryByIid(m.getId()); |
|
|
|
if (splitInventoryByIid != null) { |
|
|
|
// 如果存在拆单库存处理记录
|
|
|
|
|
|
|
|
// 获取拆单信息
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventoryByIid.getSid()); |
|
|
|
if (Integer.compare(m.getQuantity(), 0) == 0) { |
|
|
|
m.setShowQuantity(splitInfo.getNewUnit() + ":" + splitInventoryByIid.getSaveQuantity()); |
|
|
|
} else { |
|
|
|
m.setShowQuantity(m.getUnit() + ":" + m.getQuantity() + "," + splitInfo.getNewUnit() + ":" + splitInventoryByIid.getSaveQuantity()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
m.setShowQuantity(m.getUnit() + ":" + m.getQuantity()); |
|
|
|
} |
|
|
|
result.add(m); |
|
|
|
} |
|
|
|
return result; |
|
|
|
@ -686,6 +709,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据仓库查询物品 |
|
|
|
* |
|
|
|
@ -699,6 +723,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询仓库中的物料 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -722,8 +747,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
placeCode.append(placeByMidAndDid.get(j).getCode()).append(" "); |
|
|
|
} |
|
|
|
materialByDepository.get(i).setPlaceCode(placeCode.toString()); |
|
|
|
materialByDepository.get(i).setAmounts(materialByDepository.get(i).getAmounts()/100); |
|
|
|
materialByDepository.get(i).setPrice(materialByDepository.get(i).getPrice()/100); |
|
|
|
materialByDepository.get(i).setAmounts(materialByDepository.get(i).getAmounts() / 100); |
|
|
|
materialByDepository.get(i).setPrice(materialByDepository.get(i).getPrice() / 100); |
|
|
|
} |
|
|
|
|
|
|
|
return pack(materialByDepository); |
|
|
|
@ -745,7 +770,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
if (map.containsKey("quantity")) { |
|
|
|
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString())); |
|
|
|
int price = 0; |
|
|
|
if(map.containsKey("price")){ |
|
|
|
if (map.containsKey("price")) { |
|
|
|
price = (int) (Double.parseDouble(map.get("price").toString())); |
|
|
|
} |
|
|
|
map.put("price", price); |
|
|
|
@ -753,8 +778,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
// params.put("code", map.get("code"));
|
|
|
|
params.put("mname",map.get("mname")); |
|
|
|
params.put("version",map.get("version")); |
|
|
|
params.put("mname", map.get("mname")); |
|
|
|
params.put("version", map.get("version")); |
|
|
|
params.put("depositoryId", map.get("depositoryId")); |
|
|
|
List<Inventory> inventory = materialMapper.findInventoryForImport(params); |
|
|
|
if (inventory.size() >= 1) { |
|
|
|
@ -765,7 +790,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
Inventory material = inventory.get(0); |
|
|
|
|
|
|
|
Double price = 0.0; |
|
|
|
if(map.containsKey("price")){ |
|
|
|
if (map.containsKey("price")) { |
|
|
|
price = (Double.parseDouble(map.get("price").toString())) / 100; |
|
|
|
} |
|
|
|
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString())); |
|
|
|
@ -829,13 +854,12 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
} |
|
|
|
return materialMapper.updateInventory(material); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 用于标志是新插入的物料
|
|
|
|
map.put("isNew", true); |
|
|
|
if(!map.containsKey("producedDate")){ |
|
|
|
if (!map.containsKey("producedDate")) { |
|
|
|
// 如果不包含生产日期
|
|
|
|
map.put("producedDate",0); |
|
|
|
map.put("producedDate", 0); |
|
|
|
} |
|
|
|
return materialMapper.insertInventory(map); |
|
|
|
} |
|
|
|
@ -892,8 +916,16 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
List<MaterialAndBarCode> materialByBarCodeByCondition = materialMapper.findMaterialByBarCodeByCondition(map); |
|
|
|
if (materialByBarCodeByCondition.size() > 0) { |
|
|
|
MaterialAndBarCode materialAndBarCode = materialByBarCodeByCondition.get(0); |
|
|
|
if (materialAndBarCode.getIid() != null) { |
|
|
|
Inventory inventoryByMid = materialMapper.findInventoryById(materialAndBarCode.getIid()); |
|
|
|
if (inventoryByMid != null) { |
|
|
|
materialAndBarCode.setPrice(inventoryByMid.getPrice() / 100); |
|
|
|
} else { |
|
|
|
materialAndBarCode.setPrice(0.0); |
|
|
|
} |
|
|
|
} else { |
|
|
|
materialAndBarCode.setPrice(0.0); |
|
|
|
} |
|
|
|
return materialAndBarCode; |
|
|
|
} |
|
|
|
return null; |
|
|
|
@ -1014,7 +1046,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
List<Object> childList = (List<Object>) jsonObject.get("children"); |
|
|
|
List<Object> objectList1 = rewriteTree(childList, stringObjectMap, mtLevel - 1, mt,1); |
|
|
|
List<Object> objectList1 = rewriteTree(childList, stringObjectMap, mtLevel - 1, mt, 1); |
|
|
|
jsonObject.put("children", objectList1); |
|
|
|
jsonObject.remove("spread"); |
|
|
|
stringObjectMap.remove("spread"); |
|
|
|
@ -1168,7 +1200,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
Integer mtLevel = getMtLevel(mt, 1); |
|
|
|
List<MaterialType> materialTypeByParent = materialTypeMapper.findMaterialTypeByParent(mtId); |
|
|
|
|
|
|
|
if(materialTypeByParent.size() > 0) { |
|
|
|
if (materialTypeByParent.size() > 0) { |
|
|
|
// 获取当前redis中的树
|
|
|
|
List<String> objectList = redisTemplate.opsForList().range("wms_materialTree_result", 0, -1); |
|
|
|
|
|
|
|
@ -1200,6 +1232,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于修改库位中的物料 |
|
|
|
* |
|
|
|
* @param map 修改条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -1226,10 +1259,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
int beforeQuantity = pidAndmidForBefore.getQuantity() - quantity; |
|
|
|
|
|
|
|
// 判断转移到的库位是否超出库存
|
|
|
|
if(toPlace.getQuantity() + quantity > toPlace.getMax()){ |
|
|
|
if (toPlace.getQuantity() + quantity > toPlace.getMax()) { |
|
|
|
// 如果超出最大存储量
|
|
|
|
return -1; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 如果没有超出最大存储量
|
|
|
|
|
|
|
|
|
|
|
|
@ -1244,10 +1277,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 如果没有
|
|
|
|
|
|
|
|
// 新增对应关系
|
|
|
|
Map<String,Object> insertAfter = new HashMap<>(); |
|
|
|
insertAfter.put("mid",id); |
|
|
|
insertAfter.put("quantity",quantity); |
|
|
|
insertAfter.put("pid",toPlaceId); |
|
|
|
Map<String, Object> insertAfter = new HashMap<>(); |
|
|
|
insertAfter.put("mid", id); |
|
|
|
insertAfter.put("quantity", quantity); |
|
|
|
insertAfter.put("pid", toPlaceId); |
|
|
|
// 添加对应关系
|
|
|
|
placeService.addMaterialOnPlace(insertAfter); |
|
|
|
} |
|
|
|
@ -1278,26 +1311,27 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于真实关闭打开的树 |
|
|
|
* |
|
|
|
* @param jsonArray 传入的子列表 |
|
|
|
* @param mtLevel 当前关闭的物料类型等级 |
|
|
|
* @param mt 要关闭的类型 |
|
|
|
*/ |
|
|
|
public JSONArray closeTree(JSONArray jsonArray,Integer mtLevel,MaterialType mt){ |
|
|
|
public JSONArray closeTree(JSONArray jsonArray, Integer mtLevel, MaterialType mt) { |
|
|
|
MaterialType parent = mt; |
|
|
|
// 定义返回结果
|
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
if(mtLevel == 1){ |
|
|
|
if (mtLevel == 1) { |
|
|
|
// 如果到当前等级
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
JSONObject object = jsonArray.getJSONObject(i); |
|
|
|
Long oId = Long.valueOf(object.getString("id")); |
|
|
|
if(Long.compare(oId, mt.getOldId()) == 0){ |
|
|
|
if (Long.compare(oId, mt.getOldId()) == 0) { |
|
|
|
// 如果是当前关闭类别
|
|
|
|
object.remove("spread"); |
|
|
|
} |
|
|
|
ja.add(object); |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
for (int i = 0; i < mtLevel - 1; i++) { |
|
|
|
parent = materialTypeMapper.findMaterialTypeByOldId(parent.getParentId()); |
|
|
|
} |
|
|
|
@ -1308,7 +1342,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 如果是当前要关闭的父类
|
|
|
|
JSONArray children = object.getJSONArray("children"); |
|
|
|
JSONArray objects = closeTree(children, mtLevel - 1, mt); |
|
|
|
object.put("children",objects); |
|
|
|
object.put("children", objects); |
|
|
|
} |
|
|
|
ja.add(object); |
|
|
|
} |
|
|
|
@ -1327,11 +1361,11 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
* @param level 当前递归次数 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> rewriteTree(List<Object> childrenList, Map<String, Object> stringObjectMap, Integer flag, MaterialType mt,Integer level) { |
|
|
|
public List<Object> rewriteTree(List<Object> childrenList, Map<String, Object> stringObjectMap, Integer flag, MaterialType mt, Integer level) { |
|
|
|
if (flag != 1) { |
|
|
|
// 获取当前类型父类
|
|
|
|
mt = materialTypeMapper.findMaterialTypeByOldId(mt.getParentId()); |
|
|
|
return rewriteTree(childrenList, stringObjectMap, flag - 1, mt,level + 1); |
|
|
|
return rewriteTree(childrenList, stringObjectMap, flag - 1, mt, level + 1); |
|
|
|
} else { |
|
|
|
// 定义现在的等级
|
|
|
|
Integer nowLevel = 1; |
|
|
|
@ -1353,7 +1387,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
nowLevel++; |
|
|
|
// 获取当前下的子列表
|
|
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
|
List<Object> objectList = updateTreeChildren(children, stringObjectMap, level,nowLevel); |
|
|
|
List<Object> objectList = updateTreeChildren(children, stringObjectMap, level, nowLevel); |
|
|
|
jsonObject.put("children", objectList); |
|
|
|
jsonObject.put("spread", true); |
|
|
|
list.add(jsonObject); |
|
|
|
@ -1375,11 +1409,11 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
* @param nowLevel 现在的层次 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> updateTreeChildren(List<Object> childrenList, Map<String, Object> map, Integer level,Integer nowLevel) { |
|
|
|
public List<Object> updateTreeChildren(List<Object> childrenList, Map<String, Object> map, Integer level, Integer nowLevel) { |
|
|
|
// 获取数据中的id
|
|
|
|
Long somId = Long.valueOf(map.get("id").toString()); |
|
|
|
List<Object> children = new ArrayList<>(); |
|
|
|
if(level - nowLevel == 0) { |
|
|
|
if (level - nowLevel == 0) { |
|
|
|
// 如果不需要递归
|
|
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
|
JSONObject o = (JSONObject) childrenList.get(i); |
|
|
|
@ -1393,7 +1427,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
children.add(o); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 获取当前修改时的类型
|
|
|
|
MaterialType parent = materialTypeMapper.findMaterialTypeByOldId(somId); |
|
|
|
for (int i = 0; i < level - nowLevel; i++) { |
|
|
|
@ -1404,10 +1438,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
JSONObject o = (JSONObject) childrenList.get(i); |
|
|
|
// 获取当前子列表中的数据id
|
|
|
|
Long id = Long.valueOf(o.getString("id")); |
|
|
|
if(Long.compare(id,parent.getOldId()) == 0){ |
|
|
|
if (Long.compare(id, parent.getOldId()) == 0) { |
|
|
|
List<Object> objectList = updateTreeChildren(o.getJSONArray("children"), map, level, nowLevel + 1); |
|
|
|
o.put("children",objectList); |
|
|
|
o.put("spread",true); |
|
|
|
o.put("children", objectList); |
|
|
|
o.put("spread", true); |
|
|
|
} |
|
|
|
children.add(o); |
|
|
|
} |
|
|
|
@ -1641,7 +1675,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
flag = 2; |
|
|
|
} |
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
if(flag == 1){ |
|
|
|
if (flag == 1) { |
|
|
|
if ("".equals(mname)) { // 如果没有输入名称
|
|
|
|
|
|
|
|
for (Material material : materialByDepositorys) { |
|
|
|
@ -1652,8 +1686,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
String title = material.getMname() + ",规格型号: " + version; |
|
|
|
if (material.getDepositoryId() != null) { |
|
|
|
|
|
|
|
// 如果当前是库存
|
|
|
|
title += ",当前库存为:" + material.getQuantity(); |
|
|
|
title += ",当前库存为:" + material.getUnit() + ":" + material.getQuantity(); |
|
|
|
|
|
|
|
} |
|
|
|
map.put("title", title); |
|
|
|
map.put("id", material.getId()); |
|
|
|
@ -1670,7 +1706,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
String title = material.getMname() + ",规格型号: " + version; |
|
|
|
if (material.getDepositoryId() != null) { |
|
|
|
// 如果当前是库存
|
|
|
|
title += ",当前库存为:" + material.getQuantity(); |
|
|
|
title += ",当前库存为:" + material.getUnit() + ":" + material.getQuantity(); |
|
|
|
} |
|
|
|
map.put("title", title); |
|
|
|
map.put("id", material.getId()); |
|
|
|
@ -1678,38 +1714,59 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
if ("".equals(mname)) { // 如果没有输入名称
|
|
|
|
for (Inventory material : materialPByCondition) { |
|
|
|
for (Inventory inventory : materialPByCondition) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
String version = material.getVersion(); |
|
|
|
String version = inventory.getVersion(); |
|
|
|
if (version == null) { |
|
|
|
version = ""; |
|
|
|
} |
|
|
|
String title = material.getMname() + ",规格型号: " + version; |
|
|
|
if (material.getDepositoryId() != null) { |
|
|
|
String title = inventory.getMname() + ",规格型号: " + version; |
|
|
|
if (inventory.getDepositoryId() != null) { |
|
|
|
// 如果当前是库存
|
|
|
|
title += ",当前库存为:" + material.getQuantity(); |
|
|
|
|
|
|
|
// 获取对应拆单库存处理记录
|
|
|
|
title += ",当前库存为:" + inventory.getUnit() + ":" + inventory.getQuantity(); |
|
|
|
SplitInventory splitInventoryByIid = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
if (splitInventoryByIid != null) { |
|
|
|
// 如果存在
|
|
|
|
|
|
|
|
// 获取对应的拆单记录
|
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventoryByIid.getSid()); |
|
|
|
title += "," + splitInventoryByIid.getSaveQuantity() + splitInfoById.getNewUnit(); |
|
|
|
} |
|
|
|
} |
|
|
|
map.put("title", title); |
|
|
|
map.put("id", material.getId()); |
|
|
|
map.put("id", inventory.getId()); |
|
|
|
result.add(map); |
|
|
|
} |
|
|
|
} else { |
|
|
|
for (Inventory material : materialPByCondition) { |
|
|
|
for (Inventory inventory : materialPByCondition) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (material.getMname().contains(mname)) { |
|
|
|
String version = material.getVersion(); |
|
|
|
if (inventory.getMname().contains(mname)) { |
|
|
|
String version = inventory.getVersion(); |
|
|
|
if (version == null) { |
|
|
|
version = ""; |
|
|
|
} |
|
|
|
String title = material.getMname() + ",规格型号: " + version; |
|
|
|
if (material.getDepositoryId() != null) { |
|
|
|
String title = inventory.getMname() + ",规格型号: " + version; |
|
|
|
if (inventory.getDepositoryId() != null) { |
|
|
|
// 如果当前是库存
|
|
|
|
title += ",当前库存为:" + material.getQuantity(); |
|
|
|
// 如果当前是库存
|
|
|
|
|
|
|
|
// 获取对应拆单库存处理记录
|
|
|
|
title += ",当前库存为:" + inventory.getUnit() + ":" + inventory.getQuantity(); |
|
|
|
SplitInventory splitInventoryByIid = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
if (splitInventoryByIid != null) { |
|
|
|
// 如果存在
|
|
|
|
|
|
|
|
// 获取对应的拆单记录
|
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventoryByIid.getSid()); |
|
|
|
title += "," + splitInventoryByIid.getSaveQuantity() + splitInfoById.getNewUnit(); |
|
|
|
} |
|
|
|
} |
|
|
|
map.put("title", title); |
|
|
|
map.put("id", material.getId()); |
|
|
|
map.put("id", inventory.getId()); |
|
|
|
result.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -2017,6 +2074,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于构造物料树结构 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> InitTree_Test_New() { |
|
|
|
@ -2174,7 +2232,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", mt.getTname()); |
|
|
|
map.put("id", mt.getOldId()); |
|
|
|
map.put("parentId",mt.getParentId()); |
|
|
|
map.put("parentId", mt.getParentId()); |
|
|
|
map.put("children", children); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
@ -2203,11 +2261,12 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于构造树结构 |
|
|
|
* |
|
|
|
* @param list 树列表 |
|
|
|
* @param parentId 父级id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> buildTree_New(List<Object> list,Long parentId){ |
|
|
|
public List<Object> buildTree_New(List<Object> list, Long parentId) { |
|
|
|
// 定义树结构
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
@ -2215,7 +2274,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
JSONObject jsonObject = new JSONObject((Map<String, Object>) list.get(i)); |
|
|
|
// 获取当前父级id
|
|
|
|
Long parentId1 = jsonObject.getLong("parentId"); |
|
|
|
if(Long.compare(parentId,parentId1) == 0){ // 如果当前类型是其父类
|
|
|
|
if (Long.compare(parentId, parentId1) == 0) { // 如果当前类型是其父类
|
|
|
|
List<Object> objectList = buildTree_New(list, jsonObject.getLong("id")); // 获取当前类型的子类
|
|
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
|
children.addAll(objectList); |
|
|
|
@ -2228,9 +2287,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于构造物料树结构(通过物料名称搜索) |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> InitTreeForSelectName(String mname) { |
|
|
|
public List<Object> InitTreeForSelectName(String mname, String type) { |
|
|
|
// 获取所有物料类型
|
|
|
|
List<MaterialType> materialTypeAll = materialTypeMapper.findMaterialTypeAll(); |
|
|
|
// 物料总数
|
|
|
|
@ -2258,7 +2318,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
MaterialType materialType = materialTypeAll.get(i); |
|
|
|
if (((i + 1) % 100) == 0) { // 如果有100个开启线程进行处理
|
|
|
|
materialTypeList.add(materialType.getOldId()); |
|
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList,mname)); |
|
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type)); |
|
|
|
futureList.add(future); // 添加到结果集
|
|
|
|
materialTypeList = new ArrayList<>(); // 情况列表
|
|
|
|
} else { |
|
|
|
@ -2269,7 +2329,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
if (materialTypeList.size() > 0) { |
|
|
|
// 如果有剩余,开启线程进行处理
|
|
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList,mname)); |
|
|
|
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type)); |
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
|
|
|
|
@ -2295,10 +2355,13 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 待处理的物料类型id列表
|
|
|
|
List<Long> materialTypeIdList; |
|
|
|
String mname; |
|
|
|
// 1入库2出库3盘点
|
|
|
|
String type; |
|
|
|
|
|
|
|
public TaskTestForSelectMname(List<Long> materialTypeByCondition,String mname) { |
|
|
|
public TaskTestForSelectMname(List<Long> materialTypeByCondition, String mname, String type) { |
|
|
|
this.materialTypeIdList = materialTypeByCondition; |
|
|
|
this.mname = mname; |
|
|
|
this.type = type; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -2307,10 +2370,18 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 定义树结构结果集
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
// 查询当前物料类型id列表中的物料类型
|
|
|
|
Map<String,Object> paramForMnameAndMtid = new HashMap<>(); |
|
|
|
paramForMnameAndMtid.put("list",materialTypeIdList); |
|
|
|
paramForMnameAndMtid.put("mname",mname); |
|
|
|
List<Material> materialByTypeIds = materialMapper.findMaterialByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
|
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)) { |
|
|
|
inventoryByTypeIdsAndMname= materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid); |
|
|
|
|
|
|
|
} |
|
|
|
// 查询当前物料类型所包含的物料
|
|
|
|
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList); |
|
|
|
|
|
|
|
@ -2322,14 +2393,25 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
for (int i = 0; i < materialTypeByOldIds.size(); i++) { |
|
|
|
if("1".equals(type)) { |
|
|
|
for (MaterialType mt : materialTypeByOldIds) { |
|
|
|
// 获取当前物料类型
|
|
|
|
// 开启对应线程
|
|
|
|
Future<Object> future = completionService.submit(new MtTaskTestForSelectMname(mt, materialByTypeIds, mname, type)); |
|
|
|
// 添加到线程结果列表
|
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
}else if("2".equals(type)){ |
|
|
|
for (MaterialType mt : materialTypeByOldIds) { |
|
|
|
// 获取当前物料类型
|
|
|
|
MaterialType mt = materialTypeByOldIds.get(i); |
|
|
|
// 开启对应线程
|
|
|
|
Future<Object> future = completionService.submit(new MtTaskTestForSelectMname(mt, materialByTypeIds,mname)); |
|
|
|
MtTaskTestForSelectMname mtTaskTestForSelectMname = new MtTaskTestForSelectMname(mt, materialByTypeIds, mname, type); |
|
|
|
mtTaskTestForSelectMname.setInventoryList(inventoryByTypeIdsAndMname); |
|
|
|
Future<Object> future = completionService.submit(mtTaskTestForSelectMname); |
|
|
|
// 添加到线程结果列表
|
|
|
|
futureList.add(future); |
|
|
|
} |
|
|
|
} |
|
|
|
// 3.获取结果
|
|
|
|
for (int i = 0; i < materialTypeIdList.size(); i++) { |
|
|
|
Object result = null; |
|
|
|
@ -2349,16 +2431,24 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
|
|
|
|
// 用于执行测试新算法(通过物料名称搜索)
|
|
|
|
|
|
|
|
class MtTaskTestForSelectMname implements Callable<Object> { |
|
|
|
|
|
|
|
MaterialType mt; // 物料类型
|
|
|
|
List<Material> materiaList; // 物料列表
|
|
|
|
String mname; |
|
|
|
String type; |
|
|
|
List<Inventory> inventorys; // 库存列表
|
|
|
|
|
|
|
|
public MtTaskTestForSelectMname(MaterialType mt, List<Material> materiaList,String mname) { |
|
|
|
public MtTaskTestForSelectMname(MaterialType mt, List<Material> materiaList, String mname, String type) { |
|
|
|
this.mt = mt; |
|
|
|
this.materiaList = materiaList; |
|
|
|
this.mname = mname; |
|
|
|
this.type = type; |
|
|
|
} |
|
|
|
|
|
|
|
public void setInventoryList(List<Inventory> inventoryList) { |
|
|
|
this.inventorys = inventoryList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -2366,6 +2456,10 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
// 开启对应数量的线程
|
|
|
|
List<Material> materialList = new ArrayList<>(); |
|
|
|
List<Inventory> inventoryList = new ArrayList<>(); |
|
|
|
// 将物料打包成树结构对应结果
|
|
|
|
List<Object> objectList = new ArrayList<>(); |
|
|
|
if("1".equals(type)) { |
|
|
|
for (int i = 0; i < materiaList.size(); i++) { |
|
|
|
Material material = materiaList.get(i); |
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
|
@ -2373,8 +2467,18 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
materialList.add(material); |
|
|
|
} |
|
|
|
} |
|
|
|
// 将物料打包成树结构对应结果
|
|
|
|
List<Object> objectList = AddMaterialByTypeForSelectMname(materialList); |
|
|
|
objectList = AddMaterialByTypeForSelectMname(materialList, null); |
|
|
|
}else if("2".equals(type)){ |
|
|
|
for (int i = 0; i < inventorys.size(); i++) { |
|
|
|
Inventory inventory = inventorys.get(i); |
|
|
|
// 如果当前物料是当前物料类型下的物料
|
|
|
|
if (Long.compare(inventory.getMaterialTypeId(), mt.getOldId()) == 0) { |
|
|
|
inventoryList.add(inventory); |
|
|
|
} |
|
|
|
} |
|
|
|
objectList = AddMaterialByTypeForSelectMname(null,inventoryList); |
|
|
|
} |
|
|
|
|
|
|
|
// 封装成对应的结构
|
|
|
|
Map<String, Object> objectMap = InitTreeMenusForSelectName(mt, objectList); |
|
|
|
return objectMap; |
|
|
|
@ -2387,7 +2491,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("title", mt.getTname()); |
|
|
|
map.put("id", mt.getOldId()); |
|
|
|
map.put("parentId",mt.getParentId()); |
|
|
|
map.put("parentId", mt.getParentId()); |
|
|
|
map.put("children", children); |
|
|
|
return map; |
|
|
|
} else { |
|
|
|
@ -2396,37 +2500,61 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
} |
|
|
|
|
|
|
|
// 在类别后添加物料名称(通过物料名称搜索)
|
|
|
|
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList) { |
|
|
|
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList,List<Inventory> inventoryList) { |
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
for (int i = 0; i < materialList.size(); i++) { |
|
|
|
Material material = materialList.get(i); |
|
|
|
if(materialList!=null) { |
|
|
|
for (Material material : materialList) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
String version = material.getVersion(); |
|
|
|
if (version == null) { |
|
|
|
version = ""; |
|
|
|
} |
|
|
|
|
|
|
|
String title = material.getMname() + ",规格型号: " + 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 = ""; |
|
|
|
} |
|
|
|
String title = ""; |
|
|
|
title = inventory.getMname() + ",规格型号: " + version+",库存数量:"+inventory.getUnit() +":"+inventory.getQuantity(); |
|
|
|
// 获取对应拆单库存处理记录
|
|
|
|
SplitInventory splitInventoryByIid = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
if(splitInventoryByIid != null){ |
|
|
|
// 如果不为空
|
|
|
|
|
|
|
|
// 获取对应拆单信息
|
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventoryByIid.getSid()); |
|
|
|
title +=","+splitInfoById.getNewUnit()+":"+splitInventoryByIid.getSaveQuantity(); |
|
|
|
} |
|
|
|
map.put("title", title); |
|
|
|
map.put("id", inventory.getId()); |
|
|
|
result.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于构造树结构(通过物料名称搜索) |
|
|
|
* |
|
|
|
* @param list 树列表 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<Object> buildTreeForSelectName(List<Object> list){ |
|
|
|
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){ |
|
|
|
if (children.size() > 0) { |
|
|
|
result.add(jsonObject); |
|
|
|
} |
|
|
|
} |
|
|
|
|