|
|
@ -70,8 +70,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
Integer shelfLife = 0; |
|
|
Integer shelfLife = 0; |
|
|
if (map.containsKey("shelfLife")) { |
|
|
if (map.containsKey("shelfLife")) { |
|
|
String shelfLife1 = (String) map.get("shelfLife"); |
|
|
String shelfLife1 = (String) map.get("shelfLife"); |
|
|
if(!("".equals(shelfLife1))){ |
|
|
if (!("".equals(shelfLife1))) { |
|
|
shelfLife = ObjectFormatUtil.toInteger(shelfLife1); |
|
|
shelfLife = ObjectFormatUtil.toInteger(shelfLife1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (map.containsKey("producedDate")) { |
|
|
if (map.containsKey("producedDate")) { |
|
|
@ -80,13 +80,13 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
String dateType = (String) map.get("dateType"); |
|
|
String dateType = (String) map.get("dateType"); |
|
|
// 1年2月3天
|
|
|
// 1年2月3天
|
|
|
if("day".equals(dateType) && shelfLife != 0){ |
|
|
if ("day".equals(dateType) && shelfLife != 0) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("3"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("3" + shelfLife)); |
|
|
}else if("month".equals(dateType) && shelfLife != 0){ |
|
|
} else if ("month".equals(dateType) && shelfLife != 0) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("2"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("2" + shelfLife)); |
|
|
}else if("year".equals(dateType) && shelfLife != 0){ |
|
|
} else if ("year".equals(dateType) && shelfLife != 0) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("1"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("1" + shelfLife)); |
|
|
}else{ |
|
|
} else { |
|
|
map.remove("shelfLife"); |
|
|
map.remove("shelfLife"); |
|
|
} |
|
|
} |
|
|
// 获取当前类型
|
|
|
// 获取当前类型
|
|
|
@ -141,14 +141,14 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 1年2月3天
|
|
|
// 1年2月3天
|
|
|
Integer shelfLife = 0; |
|
|
Integer shelfLife = 0; |
|
|
if (map.containsKey("shelfLife")) { |
|
|
if (map.containsKey("shelfLife")) { |
|
|
shelfLife = ObjectFormatUtil.toInteger(map.get("shelfLife")); |
|
|
shelfLife = ObjectFormatUtil.toInteger(map.get("shelfLife")); |
|
|
} |
|
|
} |
|
|
if("day".equals(dateType)){ |
|
|
if ("day".equals(dateType)) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("3"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("3" + shelfLife)); |
|
|
}else if("month".equals(dateType)){ |
|
|
} else if ("month".equals(dateType)) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("2"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("2" + shelfLife)); |
|
|
}else if("year".equals(dateType)){ |
|
|
} else if ("year".equals(dateType)) { |
|
|
map.put("shelfLife",ObjectFormatUtil.toInteger("1"+shelfLife)); |
|
|
map.put("shelfLife", ObjectFormatUtil.toInteger("1" + shelfLife)); |
|
|
} |
|
|
} |
|
|
if (map.containsKey("producedDate")) { |
|
|
if (map.containsKey("producedDate")) { |
|
|
Long producedDate = DateUtil.DateTimeByMonthToTimeStamp(map.get("producedDate").toString()); |
|
|
Long producedDate = DateUtil.DateTimeByMonthToTimeStamp(map.get("producedDate").toString()); |
|
|
@ -325,19 +325,19 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
material.setShowProducedDate(DateUtil.TimeStampToDateTimeForMonth(producedDate)); |
|
|
material.setShowProducedDate(DateUtil.TimeStampToDateTimeForMonth(producedDate)); |
|
|
} |
|
|
} |
|
|
Long life = material.getShelfLife(); |
|
|
Long life = material.getShelfLife(); |
|
|
if(life != null) { |
|
|
if (life != null) { |
|
|
String shelfLife = String.valueOf(life); |
|
|
String shelfLife = String.valueOf(life); |
|
|
String dateType = shelfLife.substring(0, 1); |
|
|
String dateType = shelfLife.substring(0, 1); |
|
|
if("1".equals(dateType)){ |
|
|
if ("1".equals(dateType)) { |
|
|
material.setShowShelfLife("year"); |
|
|
material.setShowShelfLife("year"); |
|
|
}else if("2".equals(dateType)){ |
|
|
} else if ("2".equals(dateType)) { |
|
|
material.setShowShelfLife("month"); |
|
|
material.setShowShelfLife("month"); |
|
|
}else if("3".equals(dateType)){ |
|
|
} else if ("3".equals(dateType)) { |
|
|
material.setShowShelfLife("day"); |
|
|
material.setShowShelfLife("day"); |
|
|
} |
|
|
} |
|
|
//1年2月3天,后面为数目
|
|
|
//1年2月3天,后面为数目
|
|
|
|
|
|
|
|
|
material.setShelfLife(Long.valueOf(shelfLife.substring(1, shelfLife.length()))); |
|
|
material.setShelfLife(Long.valueOf(shelfLife.substring(1))); |
|
|
} |
|
|
} |
|
|
return material; |
|
|
return material; |
|
|
} |
|
|
} |
|
|
@ -455,19 +455,19 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 获取当天时间
|
|
|
// 获取当天时间
|
|
|
Long nowDay = DateUtil.DateTimeByMonthToTimeStamp(currentDate); |
|
|
Long nowDay = DateUtil.DateTimeByMonthToTimeStamp(currentDate); |
|
|
Long life = material.getShelfLife(); |
|
|
Long life = material.getShelfLife(); |
|
|
if(life != null) { |
|
|
if (life != null) { |
|
|
String shelfLife = String.valueOf(life); |
|
|
String shelfLife = String.valueOf(life); |
|
|
String dateType = shelfLife.substring(0, 1); |
|
|
String dateType = shelfLife.substring(0, 1); |
|
|
String dateTime = shelfLife.substring(1, shelfLife.length()); |
|
|
String dateTime = shelfLife.substring(1); |
|
|
if("1".equals(dateType)){ |
|
|
if ("1".equals(dateType)) { |
|
|
m.setShelfLife(dateTime+"年"); |
|
|
m.setShelfLife(dateTime + "年"); |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 365 * DateUtil.dayTime; |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 365 * DateUtil.dayTime; |
|
|
}else if("2".equals(dateType)){ |
|
|
} else if ("2".equals(dateType)) { |
|
|
m.setShelfLife(dateTime+"月"); |
|
|
m.setShelfLife(dateTime + "月"); |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 30 * DateUtil.dayTime; |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * 30 * DateUtil.dayTime; |
|
|
}else if("3".equals(dateType)){ |
|
|
} else if ("3".equals(dateType)) { |
|
|
m.setShelfLife(dateTime+"天"); |
|
|
m.setShelfLife(dateTime + "天"); |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * DateUtil.dayTime; |
|
|
calcShelfLife = ObjectFormatUtil.toLong(dateTime) * DateUtil.dayTime; |
|
|
} |
|
|
} |
|
|
// 获取当前没有使用完成的物料对应的生产日期对应
|
|
|
// 获取当前没有使用完成的物料对应的生产日期对应
|
|
|
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(m.getId()); |
|
|
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(m.getId()); |
|
|
@ -475,7 +475,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 获取当前入库时的生产日期
|
|
|
// 获取当前入库时的生产日期
|
|
|
Long producedDate1 = materialAndProducedDate.getProducedDate(); |
|
|
Long producedDate1 = materialAndProducedDate.getProducedDate(); |
|
|
// 如果可使用时间(生产时间+保质期)减去当天时间 小于预警时间
|
|
|
// 如果可使用时间(生产时间+保质期)减去当天时间 小于预警时间
|
|
|
if((producedDate1 + calcShelfLife) - nowDay < DateUtil.warningTime){ |
|
|
if ((producedDate1 + calcShelfLife) - nowDay < DateUtil.warningTime) { |
|
|
warningCount += materialAndProducedDate.getInventory(); |
|
|
warningCount += materialAndProducedDate.getInventory(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -746,9 +746,9 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<Object> AddInitTreeMenus(Map<String, Object> map) { |
|
|
public List<Object> AddInitTreeMenus(Map<String, Object> map) { |
|
|
Integer mtId = ObjectFormatUtil.toInteger(map.get("mtId")); |
|
|
Long mtId = Long.valueOf(map.get("mtId").toString()); |
|
|
List<Object> result = new ArrayList<>(); |
|
|
List<Object> result = new ArrayList<>(); |
|
|
MaterialType mt = materialTypeMapper.findMaterialTypeById(mtId); |
|
|
MaterialType mt = materialTypeMapper.findMaterialTypeByOldId(mtId); |
|
|
List<MaterialType> materialTypeByParent = materialTypeMapper.findMaterialTypeByParent(mt.getOldId()); |
|
|
List<MaterialType> materialTypeByParent = materialTypeMapper.findMaterialTypeByParent(mt.getOldId()); |
|
|
// 获取当前类别级别
|
|
|
// 获取当前类别级别
|
|
|
Integer mtLevel = getMtLevel(mt, 1); |
|
|
Integer mtLevel = getMtLevel(mt, 1); |
|
|
@ -787,17 +787,19 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
if (Long.compare(parentMt.getOldId(), id) == 0) { |
|
|
if (Long.compare(parentMt.getOldId(), id) == 0) { |
|
|
|
|
|
|
|
|
if (mtLevel == 1) { |
|
|
if (mtLevel == 1) { |
|
|
|
|
|
jsonObject.remove("spread"); |
|
|
|
|
|
stringObjectMap.remove("spread"); |
|
|
redisTemplate.opsForList().set("wms_materialTree_result", i, JSONObject.toJSONString(jsonObject)); |
|
|
redisTemplate.opsForList().set("wms_materialTree_result", i, JSONObject.toJSONString(jsonObject)); |
|
|
// redisTemplate.opsForList().leftPop("wms_materialTree_result");
|
|
|
|
|
|
// redisTemplate.opsForList().leftPush("wms_materialTree_result",JSONObject.toJSONString(jsonObject));
|
|
|
|
|
|
jsonObject.put("spread", true); |
|
|
jsonObject.put("spread", true); |
|
|
stringObjectMap.put("spread", true); |
|
|
stringObjectMap.put("spread", true); |
|
|
result.add(stringObjectMap); |
|
|
result.add(stringObjectMap); |
|
|
continue; |
|
|
continue; |
|
|
} else { |
|
|
} else { |
|
|
List<Object> childList = (List<Object>) jsonObject.get("children"); |
|
|
List<Object> childList = (List<Object>) jsonObject.get("children"); |
|
|
List<Object> objectList1 = rewriteTree(childList, stringObjectMap, mtLevel - 1, mt); |
|
|
List<Object> objectList1 = rewriteTree(childList, stringObjectMap, mtLevel - 1, mt,1); |
|
|
jsonObject.put("children", objectList1); |
|
|
jsonObject.put("children", objectList1); |
|
|
|
|
|
jsonObject.remove("spread"); |
|
|
|
|
|
stringObjectMap.remove("spread"); |
|
|
redisTemplate.opsForList().set("wms_materialTree_result", i, JSONObject.toJSONString(jsonObject)); |
|
|
redisTemplate.opsForList().set("wms_materialTree_result", i, JSONObject.toJSONString(jsonObject)); |
|
|
jsonObject.put("spread", true); |
|
|
jsonObject.put("spread", true); |
|
|
stringObjectMap.put("spread", true); |
|
|
stringObjectMap.put("spread", true); |
|
|
@ -833,6 +835,16 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 设置当前树结构为打开状态 |
|
|
|
|
|
* |
|
|
|
|
|
* @param jsonObject |
|
|
|
|
|
* @param mt |
|
|
|
|
|
* @param level |
|
|
|
|
|
* @param map |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
public JSONObject setTreeChildrenSpreadIsTrue(JSONObject jsonObject, MaterialType mt, Integer level, Map<String, Object> map) { |
|
|
public JSONObject setTreeChildrenSpreadIsTrue(JSONObject jsonObject, MaterialType mt, Integer level, Map<String, Object> map) { |
|
|
if (level != 0) { |
|
|
if (level != 0) { |
|
|
MaterialType parent = mt; |
|
|
MaterialType parent = mt; |
|
|
@ -916,6 +928,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据物料id与生产日期获取对应关系 |
|
|
* 根据物料id与生产日期获取对应关系 |
|
|
|
|
|
* |
|
|
* @param map |
|
|
* @param map |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@ -924,32 +937,119 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
return materialMapper.findMaterialAndProducedDateByMidAndProducedDate(map); |
|
|
return materialMapper.findMaterialAndProducedDateByMidAndProducedDate(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于关闭当前打开的树 |
|
|
|
|
|
* |
|
|
|
|
|
* @param mtId |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void closeTreeChildren(Long mtId) { |
|
|
|
|
|
// 获取当前要关闭的物料类型
|
|
|
|
|
|
MaterialType mt = materialTypeMapper.findMaterialTypeByOldId(mtId); |
|
|
|
|
|
// 获取当前物料类型所在树的级别
|
|
|
|
|
|
Integer mtLevel = getMtLevel(mt, 1); |
|
|
|
|
|
List<MaterialType> materialTypeByParent = materialTypeMapper.findMaterialTypeByParent(mtId); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前redis中的树
|
|
|
|
|
|
List<String> objectList = redisTemplate.opsForList().range("wms_materialTree_result", 0, -1); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前最高级
|
|
|
|
|
|
MaterialType parentMt = mt; |
|
|
|
|
|
for (int i = 0; i < mtLevel - 1; i++) { |
|
|
|
|
|
parentMt = materialTypeMapper.findMaterialTypeByOldId(parentMt.getParentId()); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < objectList.size(); i++) { |
|
|
|
|
|
String s = objectList.get(i); |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
|
|
Long id = Long.valueOf(jsonObject.getString("id")); |
|
|
|
|
|
if (Long.compare(id, parentMt.getOldId()) == 0) { |
|
|
|
|
|
// 如果是打开的顶级
|
|
|
|
|
|
JSONArray children = closeTree(jsonObject.getJSONArray("children"), mtLevel - 1, mt); |
|
|
|
|
|
jsonObject.put("children",children); |
|
|
|
|
|
redisTemplate.opsForList().set("wms_materialTree_result",i,JSONObject.toJSONString(jsonObject)); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于真实关闭打开的树 |
|
|
|
|
|
* @param jsonArray 传入的子列表 |
|
|
|
|
|
* @param mtLevel 当前关闭的物料类型等级 |
|
|
|
|
|
* @param mt 要关闭的类型 |
|
|
|
|
|
*/ |
|
|
|
|
|
public JSONArray closeTree(JSONArray jsonArray,Integer mtLevel,MaterialType mt){ |
|
|
|
|
|
MaterialType parent = mt; |
|
|
|
|
|
// 定义返回结果
|
|
|
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
|
|
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){ |
|
|
|
|
|
// 如果是当前关闭类别
|
|
|
|
|
|
object.remove("spread"); |
|
|
|
|
|
} |
|
|
|
|
|
ja.add(object); |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
for (int i = 0; i < mtLevel - 1; i++) { |
|
|
|
|
|
parent = materialTypeMapper.findMaterialTypeByOldId(parent.getParentId()); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
|
|
JSONObject object = jsonArray.getJSONObject(i); |
|
|
|
|
|
Long oId = Long.valueOf(object.getString("id")); |
|
|
|
|
|
if (Long.compare(oId, parent.getOldId()) == 0) { |
|
|
|
|
|
// 如果是当前要关闭的父类
|
|
|
|
|
|
JSONArray children = object.getJSONArray("children"); |
|
|
|
|
|
JSONArray objects = closeTree(children, mtLevel - 1, mt); |
|
|
|
|
|
object.put("children",objects); |
|
|
|
|
|
} |
|
|
|
|
|
ja.add(object); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return ja; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 重构树结构 |
|
|
* 重构树结构 |
|
|
* @param childrenList |
|
|
* |
|
|
* @param stringObjectMap |
|
|
* @param childrenList 需要重构的列表 |
|
|
* @param flag |
|
|
* @param stringObjectMap 重构数据 |
|
|
* @param mt |
|
|
* @param flag 当前等级 |
|
|
|
|
|
* @param mt 类型 |
|
|
|
|
|
* @param level 当前递归次数 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public List<Object> rewriteTree(List<Object> childrenList, Map<String, Object> stringObjectMap, Integer flag, MaterialType mt) { |
|
|
public List<Object> rewriteTree(List<Object> childrenList, Map<String, Object> stringObjectMap, Integer flag, MaterialType mt,Integer level) { |
|
|
if (flag != 1) { |
|
|
if (flag != 1) { |
|
|
|
|
|
// 获取当前类型父类
|
|
|
mt = materialTypeMapper.findMaterialTypeByOldId(mt.getParentId()); |
|
|
mt = materialTypeMapper.findMaterialTypeByOldId(mt.getParentId()); |
|
|
return rewriteTree(childrenList, stringObjectMap, flag - 1, mt); |
|
|
return rewriteTree(childrenList, stringObjectMap, flag - 1, mt,level + 1); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 定义现在的等级
|
|
|
|
|
|
Integer nowLevel = 1; |
|
|
List<Object> list = new ArrayList<>(); |
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
|
|
// 获取当前类型id
|
|
|
Long somId = mt.getOldId(); |
|
|
Long somId = mt.getOldId(); |
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
|
|
|
// 获取当前树形菜单数据
|
|
|
JSONObject jsonObject = (JSONObject) childrenList.get(i); |
|
|
JSONObject jsonObject = (JSONObject) childrenList.get(i); |
|
|
|
|
|
// 获取当前菜单id
|
|
|
Long id = Long.valueOf(jsonObject.getString("id")); |
|
|
Long id = Long.valueOf(jsonObject.getString("id")); |
|
|
|
|
|
// 如果当前类型id与菜单id一致
|
|
|
if (Long.compare(somId, id) == 0) { |
|
|
if (Long.compare(somId, id) == 0) { |
|
|
|
|
|
|
|
|
Long childrenId = Long.valueOf(stringObjectMap.get("id").toString()); |
|
|
Long childrenId = Long.valueOf(stringObjectMap.get("id").toString()); |
|
|
if (Long.compare(childrenId, id) == 0) { |
|
|
if (Long.compare(childrenId, id) == 0) { |
|
|
list.add(stringObjectMap); |
|
|
list.add(stringObjectMap); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
nowLevel++; |
|
|
// 获取当前下的子列表
|
|
|
// 获取当前下的子列表
|
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
JSONArray children = jsonObject.getJSONArray("children"); |
|
|
List<Object> objectList = updateTreeChildren(children, stringObjectMap, childrenId); |
|
|
List<Object> objectList = updateTreeChildren(children, stringObjectMap, level,nowLevel); |
|
|
jsonObject.put("children", objectList); |
|
|
jsonObject.put("children", objectList); |
|
|
jsonObject.put("spread", true); |
|
|
jsonObject.put("spread", true); |
|
|
list.add(jsonObject); |
|
|
list.add(jsonObject); |
|
|
@ -962,16 +1062,49 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Object> updateTreeChildren(List<Object> childrenList, Map<String, Object> map, Long mtId) { |
|
|
/** |
|
|
|
|
|
* 修改树 |
|
|
|
|
|
* |
|
|
|
|
|
* @param childrenList 需要修改的子列表 |
|
|
|
|
|
* @param map 修改的数据 |
|
|
|
|
|
* @param level 之前递归的cis |
|
|
|
|
|
* @param nowLevel 现在的层次 |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Object> updateTreeChildren(List<Object> childrenList, Map<String, Object> map, Integer level,Integer nowLevel) { |
|
|
|
|
|
// 获取数据中的id
|
|
|
Long somId = Long.valueOf(map.get("id").toString()); |
|
|
Long somId = Long.valueOf(map.get("id").toString()); |
|
|
|
|
|
|
|
|
List<Object> children = new ArrayList<>(); |
|
|
List<Object> children = new ArrayList<>(); |
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
if(level - nowLevel == 0) { |
|
|
JSONObject o = (JSONObject) childrenList.get(i); |
|
|
// 如果不需要递归
|
|
|
Long id = Long.valueOf(o.getString("id")); |
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
if (Long.compare(somId, id) == 0) { |
|
|
JSONObject o = (JSONObject) childrenList.get(i); |
|
|
children.add(map); |
|
|
// 获取当前子列表中的数据id
|
|
|
} else { |
|
|
Long id = Long.valueOf(o.getString("id")); |
|
|
|
|
|
if (Long.compare(somId, id) == 0) { |
|
|
|
|
|
// 如果当前数据需要进行修改
|
|
|
|
|
|
children.add(map); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 添加
|
|
|
|
|
|
children.add(o); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 获取当前修改时的类型
|
|
|
|
|
|
MaterialType parent = materialTypeMapper.findMaterialTypeByOldId(somId); |
|
|
|
|
|
for (int i = 0; i < level - nowLevel; i++) { |
|
|
|
|
|
// 获取父类
|
|
|
|
|
|
parent = materialTypeMapper.findMaterialTypeByOldId(parent.getParentId()); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < childrenList.size(); i++) { |
|
|
|
|
|
JSONObject o = (JSONObject) childrenList.get(i); |
|
|
|
|
|
// 获取当前子列表中的数据id
|
|
|
|
|
|
Long id = Long.valueOf(o.getString("id")); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
children.add(o); |
|
|
children.add(o); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -1432,14 +1565,14 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
Object result = null; |
|
|
Object result = null; |
|
|
try { |
|
|
try { |
|
|
result = completionService.take().get(); |
|
|
result = completionService.take().get(); |
|
|
redisTemplate.opsForList().leftPush("wms_materialTree_result", JSON.toJSONString(result)); |
|
|
|
|
|
redisTemplate.expire("wms_materialTree_result", DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
} catch (InterruptedException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} catch (ExecutionException e) { |
|
|
} catch (ExecutionException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
list.add(result); |
|
|
list.add(result); |
|
|
|
|
|
redisTemplate.opsForList().leftPush("wms_materialTree_result", JSON.toJSONString(result)); |
|
|
|
|
|
redisTemplate.expire("wms_materialTree_result", DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|
|
} |
|
|
} |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|