|
|
@ -515,7 +515,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
map.put("did", depositoryId); |
|
|
map.put("did", depositoryId); |
|
|
Inventory inventory = materialMapper.findInventoryByMidAndDid(map); |
|
|
Inventory inventory = materialMapper.findInventoryByMidAndDid(map); |
|
|
if (inventory != null) { |
|
|
if (inventory != null) { |
|
|
result.add((double)inventory.getQuantity() / 100); |
|
|
result.add((double) inventory.getQuantity() / 100); |
|
|
} else { |
|
|
} else { |
|
|
result.add(0.0); |
|
|
result.add(0.0); |
|
|
} |
|
|
} |
|
|
@ -539,7 +539,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
for (MaterialAndPlaceForViewP materialAndPlaceForView : placeAndMaterialByDidAndMid) { |
|
|
for (MaterialAndPlaceForViewP materialAndPlaceForView : placeAndMaterialByDidAndMid) { |
|
|
paramForSplitInventory.put("iid", materialAndPlaceForView.getId()); |
|
|
paramForSplitInventory.put("iid", materialAndPlaceForView.getId()); |
|
|
MaterialAndPlace materialAndPlace = new MaterialAndPlace(); |
|
|
MaterialAndPlace materialAndPlace = new MaterialAndPlace(); |
|
|
materialAndPlace.setQuantity((int)(materialAndPlaceForView.getInventory() / 100)); |
|
|
materialAndPlace.setQuantity((int) (materialAndPlaceForView.getInventory() / 100)); |
|
|
materialAndPlace.setId(materialAndPlaceForView.getId()); |
|
|
materialAndPlace.setId(materialAndPlaceForView.getId()); |
|
|
quantity += splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, splitInfo.getId(), 0, true); |
|
|
quantity += splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, splitInfo.getId(), 0, true); |
|
|
} |
|
|
} |
|
|
@ -569,8 +569,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
List<MaterialAndPlaceForViewP> placeAndMaterialByDidsAndMid = placeService.findPlaceAndMaterialByDidsAndMid(depositoryList, map); |
|
|
List<MaterialAndPlaceForViewP> placeAndMaterialByDidsAndMid = placeService.findPlaceAndMaterialByDidsAndMid(depositoryList, map); |
|
|
if (placeAndMaterialByDidsAndMid.size() > 0) { |
|
|
if (placeAndMaterialByDidsAndMid.size() > 0) { |
|
|
// 如果存在库存记录
|
|
|
// 如果存在库存记录
|
|
|
for (MaterialAndPlaceForViewP materialByDidsAndMid:placeAndMaterialByDidsAndMid |
|
|
for (MaterialAndPlaceForViewP materialByDidsAndMid : placeAndMaterialByDidsAndMid |
|
|
) { |
|
|
) { |
|
|
materialByDidsAndMid.setInventory(materialByDidsAndMid.getInventory() / 100); |
|
|
materialByDidsAndMid.setInventory(materialByDidsAndMid.getInventory() / 100); |
|
|
} |
|
|
} |
|
|
return packMpvList(placeAndMaterialByDidsAndMid, map); |
|
|
return packMpvList(placeAndMaterialByDidsAndMid, map); |
|
|
@ -795,8 +795,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Double> splitInventoryForUnit = new HashMap<>(); |
|
|
Map<String, Double> splitInventoryForUnit = new HashMap<>(); |
|
|
splitInventoryForUnit.put(inventory.getUnit(), (double)inventory.getQuantity() / 100); |
|
|
splitInventoryForUnit.put(inventory.getUnit(), (double) inventory.getQuantity() / 100); |
|
|
m.setBaseUnitQuantity((double)inventory.getQuantity() / 100); |
|
|
m.setBaseUnitQuantity((double) inventory.getQuantity() / 100); |
|
|
|
|
|
|
|
|
// 定义最后展示单位及数目
|
|
|
// 定义最后展示单位及数目
|
|
|
String unit = inventory.getUnit(); |
|
|
String unit = inventory.getUnit(); |
|
|
@ -955,7 +955,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
@Override |
|
|
@Override |
|
|
public Integer insertInventoryForImport(Map<String, Object> map) { |
|
|
public Integer insertInventoryForImport(Map<String, Object> map) { |
|
|
if (!map.containsKey("quantity")) { |
|
|
if (!map.containsKey("quantity")) { |
|
|
map.put("quantity",0); |
|
|
map.put("quantity", 0); |
|
|
} |
|
|
} |
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
// params.put("code", map.get("code"));
|
|
|
// params.put("code", map.get("code"));
|
|
|
@ -972,41 +972,75 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double quantity = Double.parseDouble(map.get("quantity").toString()); |
|
|
double quantity = Double.parseDouble(map.get("quantity").toString()); |
|
|
material.setQuantity(material.getQuantity() + (int)(quantity * 100)); |
|
|
double quantity_residue = 0; |
|
|
|
|
|
int splitInfoScaleQuantity = 0; |
|
|
|
|
|
SplitInfo baseSplitInfoForMid = null; |
|
|
|
|
|
if (Math.floor(quantity) < quantity) { |
|
|
|
|
|
// 如果当前导入的物料存在小数
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前物料对应的最小拆单单位
|
|
|
|
|
|
baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getMid()); |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
// 获取当前拆单单位与基础单位的进制
|
|
|
|
|
|
splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1); |
|
|
|
|
|
quantity_residue = quantity - Math.floor(quantity); |
|
|
|
|
|
quantity = quantity - quantity_residue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
material.setQuantity(material.getQuantity() + (int) (quantity * 100)); |
|
|
|
|
|
|
|
|
// 获取当前物料要存入的库位
|
|
|
// 获取当前物料要存入的库位
|
|
|
String tempPlaceCode = (String) map.get("tempPlaceCode"); |
|
|
String tempPlaceCode = (String) map.get("tempPlaceCode"); |
|
|
if ("0".equals(tempPlaceCode)) { |
|
|
if ("0".equals(tempPlaceCode) || "0000".equals(tempPlaceCode) || "000000".equals(tempPlaceCode)) { |
|
|
// 如果当前导入库位是默认库位
|
|
|
// 如果当前导入库位是默认库位
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, material.getId()); |
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, material.getId()); |
|
|
|
|
|
|
|
|
if (placeAndMaterialByMidAndPid != null) { |
|
|
if (placeAndMaterialByMidAndPid != null) { |
|
|
// 修改当前库位数目
|
|
|
// 修改当前库位数目
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int)(quantity * 100)); |
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 如果没有对应关系
|
|
|
// 如果没有对应关系
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
param.put("pid", 0); |
|
|
param.put("pid", 0); |
|
|
param.put("mid", material.getId()); |
|
|
param.put("mid", material.getId()); |
|
|
param.put("quantity", (int)(quantity * 100)); |
|
|
param.put("quantity", (int) (quantity * 100)); |
|
|
// 添加对应关系
|
|
|
// 添加对应关系
|
|
|
placeService.addMaterialOnPlace(param); |
|
|
placeService.addMaterialOnPlace(param); |
|
|
|
|
|
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// 修改库位存放数量
|
|
|
// 修改库位存放数量
|
|
|
Place placeById = placeService.findPlaceById(0); |
|
|
Place placeById = placeService.findPlaceById(0); |
|
|
placeById.setQuantity(placeById.getQuantity() + (int)(quantity * 100)); |
|
|
placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); |
|
|
placeService.UpdatePlace(placeById); |
|
|
placeService.UpdatePlace(placeById); |
|
|
|
|
|
|
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("depositoryId", map.get("depositoryId")); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue * splitInfoScaleQuantity); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("placeId", "0"); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("mid", material.getMid().toString()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("newInMid", material.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); |
|
|
|
|
|
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); |
|
|
|
|
|
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); |
|
|
|
|
|
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { |
|
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 如果要导入的不是默认库位
|
|
|
// 如果要导入的不是默认库位
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
param.put("depositoryId", material.getDepositoryId()); |
|
|
param.put("depositoryId", material.getDepositoryId()); |
|
|
param.put("code", tempPlaceCode); |
|
|
param.put("kingdeecode", tempPlaceCode); |
|
|
// 获取要导入的库位
|
|
|
// 获取要导入的库位
|
|
|
Place placeByCondition = placeService.findPlaceByCondition(param).get(0); |
|
|
Place placeByCondition = placeService.findPlaceByCondition(param).get(0); |
|
|
// 修改库位物料数量
|
|
|
// 修改库位物料数量
|
|
|
placeByCondition.setQuantity(placeByCondition.getQuantity() + (int)(quantity * 100)); |
|
|
placeByCondition.setQuantity(placeByCondition.getQuantity() + (int) (quantity * 100)); |
|
|
placeService.UpdatePlace(placeByCondition); |
|
|
placeService.UpdatePlace(placeByCondition); |
|
|
|
|
|
|
|
|
// 获取库位与物料的对应关系
|
|
|
// 获取库位与物料的对应关系
|
|
|
@ -1015,22 +1049,43 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 如果没有对应关系
|
|
|
// 如果没有对应关系
|
|
|
param.put("pid", placeByCondition.getId()); |
|
|
param.put("pid", placeByCondition.getId()); |
|
|
param.put("mid", material.getId()); |
|
|
param.put("mid", material.getId()); |
|
|
param.put("quantity", (int)(quantity * 100)); |
|
|
param.put("quantity", (int) (quantity * 100)); |
|
|
// 添加对应关系
|
|
|
// 添加对应关系
|
|
|
placeService.addMaterialOnPlace(param); |
|
|
placeService.addMaterialOnPlace(param); |
|
|
|
|
|
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); |
|
|
} else { |
|
|
} else { |
|
|
// 如果有对应关系
|
|
|
// 如果有对应关系
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int)(quantity * 100)); |
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
// 修改数量
|
|
|
// 修改数量
|
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
} |
|
|
} |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("depositoryId", map.get("depositoryId")); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue * splitInfoScaleQuantity); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("placeId", placeByCondition.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("mid", material.getMid().toString()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("newInMid", material.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("type", "in"); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); |
|
|
|
|
|
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); |
|
|
|
|
|
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); |
|
|
|
|
|
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { |
|
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return materialMapper.updateInventory(material); |
|
|
return materialMapper.updateInventory(material); |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 用于标志是新插入的物料
|
|
|
// 用于标志是新插入的物料
|
|
|
map.put("isNew", true); |
|
|
map.put("isNew", true); |
|
|
map.put("quantity",(int)(ObjectFormatUtil.toDouble(map.get("quantity")) * 100)); |
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
|
|
|
map.put("quantity", (int) (quantity * 100)); |
|
|
|
|
|
|
|
|
|
|
|
SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(ObjectFormatUtil.toInteger(map.get("id"))); |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
map.put("quantity", (int) ((quantity - Math.floor(quantity)) * 100)); |
|
|
|
|
|
} |
|
|
if (!map.containsKey("producedDate")) { |
|
|
if (!map.containsKey("producedDate")) { |
|
|
// 如果不包含生产日期
|
|
|
// 如果不包含生产日期
|
|
|
map.put("producedDate", 0); |
|
|
map.put("producedDate", 0); |
|
|
@ -1686,7 +1741,7 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 如果当前转移的数量大于进制数
|
|
|
// 如果当前转移的数量大于进制数
|
|
|
|
|
|
|
|
|
// 获取进位数量
|
|
|
// 获取进位数量
|
|
|
int dispose = (int)( Math.floor(quantity / (double) splitInfo.getQuantity())); |
|
|
int dispose = (int) (Math.floor(quantity / (double) splitInfo.getQuantity())); |
|
|
// 获取当前入库数量
|
|
|
// 获取当前入库数量
|
|
|
int realQuantity = quantity - dispose * splitInfo.getQuantity(); |
|
|
int realQuantity = quantity - dispose * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
@ -2624,8 +2679,8 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
map.remove("placeId"); |
|
|
map.remove("placeId"); |
|
|
} |
|
|
} |
|
|
List<MaterialAndPlaceForViewP> placeAndMaterialByCondition = placeService.findPlaceAndMaterialByCondition(map); |
|
|
List<MaterialAndPlaceForViewP> placeAndMaterialByCondition = placeService.findPlaceAndMaterialByCondition(map); |
|
|
for (MaterialAndPlaceForViewP placeAndPlaceForViewP:placeAndMaterialByCondition |
|
|
for (MaterialAndPlaceForViewP placeAndPlaceForViewP : placeAndMaterialByCondition |
|
|
) { |
|
|
) { |
|
|
placeAndPlaceForViewP.setInventory(placeAndPlaceForViewP.getInventory() / 100); |
|
|
placeAndPlaceForViewP.setInventory(placeAndPlaceForViewP.getInventory() / 100); |
|
|
} |
|
|
} |
|
|
return packMpvList(placeAndMaterialByCondition, map); |
|
|
return packMpvList(placeAndMaterialByCondition, map); |
|
|
@ -2673,13 +2728,13 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
mpv.setTakingInventory(number); |
|
|
mpv.setTakingInventory(number); |
|
|
if ("Inventory_down".equals(takingResult)) { |
|
|
if ("Inventory_down".equals(takingResult)) { |
|
|
// 如果盘亏
|
|
|
// 如果盘亏
|
|
|
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) - ObjectFormatUtil.toDouble(number))); |
|
|
mpv.setStockTakingQuantity((int) (splitInventory.get(unit) - ObjectFormatUtil.toDouble(number))); |
|
|
} else if ("Inventory_up".equals(takingResult)) { |
|
|
} else if ("Inventory_up".equals(takingResult)) { |
|
|
// 如果盘盈
|
|
|
// 如果盘盈
|
|
|
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) + ObjectFormatUtil.toDouble(number))); |
|
|
mpv.setStockTakingQuantity((int) (splitInventory.get(unit) + ObjectFormatUtil.toDouble(number))); |
|
|
} else { |
|
|
} else { |
|
|
// 如果正常
|
|
|
// 如果正常
|
|
|
mpv.setStockTakingQuantity((int)(splitInventory.get(unit) * 100)); |
|
|
mpv.setStockTakingQuantity((int) (splitInventory.get(unit) * 100)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|