Browse Source

修改库存盘点功能

lwx_dev
erdanergou 3 years ago
parent
commit
e2a905a671
  1. 10
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  2. 14
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java
  3. 34
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  4. 2
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialTypeServiceImpl.java
  5. 50
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

10
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -731,8 +731,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate);
if (materialAndProducedDateByMidAndProducedDate != null) {
// 增加当前数量
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + (int) quantity * 100);
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + (int) quantity * 100);
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + (int) (quantity * 100));
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + (int) (quantity * 100));
// 修改
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate);
} else {
@ -769,12 +769,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 插入记录
placeMapper.addMaterialOnPlace(insert);
} else {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) quantity * 100);
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100));
// 修改数量
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
}
// 修改当前库位数量
placeById.setQuantity(placeById.getQuantity() + (int) quantity * 100);
placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100));
return placeMapper.UpdatePlace(placeById);
}
@ -1686,7 +1686,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// redisTemplate.opsForHash().put(redisMinRecordKey,"manager",userByPort.getId().toString());
// 修改当前已经出库的数量
applicationOutMinById.setTrueOut((int) (trueOut * 100) + applicationOutMinById.getTrueOut());
applicationOutMinById.setTrueOut((int) ((trueOut * 100) + applicationOutMinById.getTrueOut()));
if (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut() > 0) {
// 如果当前子订单中的物料并未完全出库
depositoryRecordMapper.updateApplicationOutRecordMin(applicationOutMinById);

14
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -264,7 +264,7 @@ public class ExcelServiceImpl implements ExcelService {
// 如果有库位
Place place = placeByCondition.get(0);
// 如果库位有物料且该库位存放的物料为当前物料
Integer quantity = ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity());
int quantity = (int)(ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()) * 100);
if (quantity > place.getMax() - place.getQuantity()) {
// 如果当前库位无法放下
String s = dataIndex.get(i);
@ -309,9 +309,9 @@ public class ExcelServiceImpl implements ExcelService {
// 添加库存记录
Integer depositoryId = excelInfoByInventory.getDepositoryId();
Double quantity = ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity());
insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode());
insert.put("quantity", String.valueOf(ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity())));
insert.put("quantity", String.valueOf(quantity));
insert.put("depositoryId", depositoryId);
insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode());
insert.put("mid", material.getId());
@ -329,12 +329,12 @@ public class ExcelServiceImpl implements ExcelService {
// 获取默认库位
Place placeById = placeService.findPlaceById(0);
// 修改默认库位库存
placeById.setQuantity(placeById.getQuantity() + ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity()));
placeById.setQuantity(placeById.getQuantity() + (int)(quantity * 100));
placeService.UpdatePlace(placeById);
// 添加库位与物料的映射
param.put("mid", insert.get("id"));
param.put("pid", 0);
param.put("quantity", ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity()));
param.put("quantity", (int)(quantity * 100));
placeService.addMaterialOnPlace(param);
} else {
// 如果输入的库位不是默认库位
@ -345,13 +345,13 @@ public class ExcelServiceImpl implements ExcelService {
Place placeByCondition = placeService.findPlaceByCondition(param).get(0);
// 修改库位物料数量
placeByCondition.setQuantity(placeByCondition.getQuantity() + ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity()));
placeByCondition.setQuantity(placeByCondition.getQuantity() + (int)(quantity * 100));
placeService.UpdatePlace(placeByCondition);
// 如果没有对应关系
param.put("pid", placeByCondition.getId());
param.put("mid", insert.get("id"));
param.put("quantity", ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity()));
param.put("quantity", (int)(quantity * 100));
// 添加对应关系
placeService.addMaterialOnPlace(param);
}

34
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -954,8 +954,8 @@ public class MaterialServiceImpl implements MaterialService {
*/
@Override
public Integer insertInventoryForImport(Map<String, Object> map) {
if (map.containsKey("quantity")) {
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString()));
if (!map.containsKey("quantity")) {
map.put("quantity",0);
}
Map<String, Object> params = new HashMap<>();
// params.put("code", map.get("code"));
@ -971,8 +971,8 @@ public class MaterialServiceImpl implements MaterialService {
Inventory material = inventory.get(0);
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString()));
material.setQuantity(material.getQuantity() + quantity);
double quantity = Double.parseDouble(map.get("quantity").toString());
material.setQuantity(material.getQuantity() + (int)(quantity * 100));
// 获取当前物料要存入的库位
String tempPlaceCode = (String) map.get("tempPlaceCode");
@ -982,7 +982,7 @@ public class MaterialServiceImpl implements MaterialService {
if (placeAndMaterialByMidAndPid != null) {
// 修改当前库位数目
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity);
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int)(quantity * 100));
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
} else {
@ -990,13 +990,13 @@ public class MaterialServiceImpl implements MaterialService {
Map<String, Object> param = new HashMap<>();
param.put("pid", 0);
param.put("mid", material.getId());
param.put("quantity", quantity);
param.put("quantity", (int)(quantity * 100));
// 添加对应关系
placeService.addMaterialOnPlace(param);
}
// 修改库位存放数量
Place placeById = placeService.findPlaceById(0);
placeById.setQuantity(placeById.getQuantity() + quantity);
placeById.setQuantity(placeById.getQuantity() + (int)(quantity * 100));
placeService.UpdatePlace(placeById);
} else {
// 如果要导入的不是默认库位
@ -1006,7 +1006,7 @@ public class MaterialServiceImpl implements MaterialService {
// 获取要导入的库位
Place placeByCondition = placeService.findPlaceByCondition(param).get(0);
// 修改库位物料数量
placeByCondition.setQuantity(placeByCondition.getQuantity() + quantity);
placeByCondition.setQuantity(placeByCondition.getQuantity() + (int)(quantity * 100));
placeService.UpdatePlace(placeByCondition);
// 获取库位与物料的对应关系
@ -1015,20 +1015,22 @@ public class MaterialServiceImpl implements MaterialService {
// 如果没有对应关系
param.put("pid", placeByCondition.getId());
param.put("mid", material.getId());
param.put("quantity", quantity);
param.put("quantity", (int)(quantity * 100));
// 添加对应关系
placeService.addMaterialOnPlace(param);
} else {
// 如果有对应关系
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity);
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int)(quantity * 100));
// 修改数量
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
}
}
return materialMapper.updateInventory(material);
} else {
}
else {
// 用于标志是新插入的物料
map.put("isNew", true);
map.put("quantity",(int)(ObjectFormatUtil.toDouble(map.get("quantity")) * 100));
if (!map.containsKey("producedDate")) {
// 如果不包含生产日期
map.put("producedDate", 0);
@ -1531,7 +1533,7 @@ public class MaterialServiceImpl implements MaterialService {
// 获取当前单位对应的进制
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 计算当前转移数目对应需要减少的数目
int num = (int) Math.ceil(quantity / (double) scale);
int num = (int) (Math.ceil(quantity / (double) scale));
// 修改当前库存数量
inventoryByMid.setQuantity(inventoryByMid.getQuantity() - num);
@ -1586,7 +1588,7 @@ public class MaterialServiceImpl implements MaterialService {
// 如果当前转移后的总数大于进制数
// 获取当前进行进位的数
int dispose = (int) Math.floor(realQuantity / (double) splitInfo.getQuantity());
int dispose = (int) (Math.floor(realQuantity / (double) splitInfo.getQuantity()));
// 获取进位后当前入库的数量
realQuantity = realQuantity - dispose * splitInfo.getQuantity();
// 设置当前库存数量
@ -1635,7 +1637,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();
// 如果不大于
@ -1684,7 +1686,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();
@ -2475,7 +2477,7 @@ public class MaterialServiceImpl implements MaterialService {
double size = 100.0;
// 定义线程数
int threadSize = (int) Math.ceil(totalVal / size);
int threadSize = (int) (Math.ceil(totalVal / size));
// 开启对应数量的线程
ExecutorService exs = Executors.newFixedThreadPool(threadSize);

2
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialTypeServiceImpl.java

@ -213,7 +213,7 @@ public class MaterialTypeServiceImpl implements MaterialTypeService {
// 定义分页数量
double size = 100.0;
// 定义线程数
int threadSize = (int) Math.ceil(totalVal / size);
int threadSize = (int) (Math.ceil(totalVal / size));
// 定义开启线程数
int openThreadSize = 0;
// 开启对应数量的线程

50
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -825,7 +825,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果当前盘点的数量大于拆单规定的进制数量
// 计算当前进制下的进位数量
int disposeQuantity = (int) Math.round(Math.floor((double) inventory / scale));
int disposeQuantity = (int) (Math.round(Math.floor((double) inventory / scale)));
// 计算要进的数目
double quantity_in = (realQuantity / (scale));
@ -836,7 +836,7 @@ public class StockTakingServiceImpl implements StockTakingService {
realQuantity = realQuantity - quantity_in * scale;
// 设置当前数量为实际数量
splitInventory.setSaveQuantity((int) realQuantity * 100);
splitInventory.setSaveQuantity((int) (realQuantity * 100));
// 修改当前拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
@ -853,7 +853,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果不需要进位
// 修改当前库存
splitInventory.setSaveQuantity((int) realQuantity * 100);
splitInventory.setSaveQuantity((int) (realQuantity * 100));
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
@ -992,10 +992,10 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取一个数量
surplus_redundant += 1.0;
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - (int) saveQuantity * 100);
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - (int) (saveQuantity * 100));
} else {
// 如果不大于
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - (int) saveQuantity * 100);
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - (int) (saveQuantity * 100));
}
@ -1003,14 +1003,14 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果能够出库
// 令库存-1
inventoryById.setQuantity(inventoryById.getQuantity() - (int) surplus_redundant * 100);
inventoryById.setQuantity(inventoryById.getQuantity() - (int) (surplus_redundant * 100));
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - (int) surplus_redundant * 100);
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - (int) (surplus_redundant * 100));
placeById.setQuantity(placeById.getQuantity() - (int) surplus_redundant * 100);
placeById.setQuantity(placeById.getQuantity() - (int) (surplus_redundant * 100));
} else {
inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
@ -1057,7 +1057,7 @@ public class StockTakingServiceImpl implements StockTakingService {
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 获取当前盘点对应基础单位的数量
int residue = (int) Math.ceil(inventory / (double) scale);
int residue = (int) (Math.ceil(inventory / (double) scale));
// 获取剩余数目
int residue_realQuantity = residue * scale - inventory;
@ -1343,7 +1343,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果当前盘点的数量大于拆单规定的进制数量
// 计算当前进制下的进位数量
int disposeQuantity = (int) Math.round(Math.floor((double) inventory / scale));
int disposeQuantity = (int) (Math.round(Math.floor((double) inventory / scale)));
// 计算要进的数目
double quantity_in = (realQuantity / (scale));
@ -1354,7 +1354,7 @@ public class StockTakingServiceImpl implements StockTakingService {
realQuantity = realQuantity - quantity_in * scale;
// 设置当前数量为实际数量
splitInventory.setSaveQuantity((int) realQuantity * 100);
splitInventory.setSaveQuantity((int) (realQuantity * 100));
// 修改当前拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
@ -1371,7 +1371,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果不需要进位
// 修改当前库存
splitInventory.setSaveQuantity((int) realQuantity * 100);
splitInventory.setSaveQuantity((int) (realQuantity * 100));
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
@ -1510,10 +1510,10 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取一个数量
surplus_redundant += 1.0;
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - (int) saveQuantity * 100);
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - (int) (saveQuantity * 100));
} else {
// 如果不大于
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - (int) saveQuantity * 100);
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - (int) (saveQuantity * 100));
}
@ -1521,14 +1521,14 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果能够出库
// 令库存-1
inventoryById.setQuantity(inventoryById.getQuantity() - (int) surplus_redundant * 100);
inventoryById.setQuantity(inventoryById.getQuantity() - (int) (surplus_redundant * 100));
// 修改当前库位存放物料的数量
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - (int) surplus_redundant * 100);
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - (int)( surplus_redundant * 100));
placeById.setQuantity(placeById.getQuantity() - (int) surplus_redundant * 100);
placeById.setQuantity(placeById.getQuantity() - (int) (surplus_redundant * 100));
} else {
inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity());
@ -1575,7 +1575,7 @@ public class StockTakingServiceImpl implements StockTakingService {
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 获取当前盘点对应基础单位的数量
int residue = (int) Math.ceil(inventory / (double) scale);
int residue = (int)( Math.ceil(inventory / (double) scale));
// 获取剩余数目
int residue_realQuantity = residue * scale - inventory;
@ -1989,7 +1989,7 @@ public class StockTakingServiceImpl implements StockTakingService {
if (Integer.compare(newPlace.getDid(), oldPlace.getDid()) != 0) {
// 转移前后不在同一仓库
inventoryById.setQuantity((int) newInventory * 100);
inventoryById.setQuantity((int)( newInventory * 100));
// 用于获取转移后仓库的物料信息
Map<String, Object> paramForMaterialToDepository = new HashMap<>();
@ -2057,7 +2057,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果当前转移数目大于进制数
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity()));
int disposeQuantity = (int) (Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity())));
// 最终存储到拆单处理的数量
double saveQuantity = inventory_transfer - disposeQuantity * splitInfo.getQuantity();
@ -2114,7 +2114,7 @@ public class StockTakingServiceImpl implements StockTakingService {
int scale = splitInfo.getQuantity();
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity()));
int disposeQuantity = (int) (Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity())));
// 最终存储到拆单处理的数量
double saveQuantity = inventory_transfer - disposeQuantity * splitInfo.getQuantity();
@ -2147,7 +2147,7 @@ public class StockTakingServiceImpl implements StockTakingService {
}
// 设置当前拆单对应的库存数量
splitInventory.setSaveQuantity((int) realQuantity * 100);
splitInventory.setSaveQuantity((int) (realQuantity * 100));
// 修改库存数量
splitUnitMapper.updateSplitInventory(splitInventory);
@ -2315,7 +2315,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity()));
int disposeQuantity = (int) (Math.round(Math.floor(inventory_transfer / (double) splitInfo.getQuantity())));
// 最终存储到拆单处理的数量
double saveQuantity = inventory_transfer - disposeQuantity * splitInfo.getQuantity();
@ -2398,7 +2398,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果当前记录存在
// 设置当前拆单库存数
splitInventory.setSaveQuantity((int) newInventory * 100);
splitInventory.setSaveQuantity((int) (newInventory * 100));
// 修改当前拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
@ -2435,7 +2435,7 @@ public class StockTakingServiceImpl implements StockTakingService {
if ("-1".equals(unit)) {
// 如果是基础单位
oldPlaceAndMaterial.setQuantity((int) newInventory * 100);
oldPlaceAndMaterial.setQuantity((int) (newInventory * 100));
placeMapper.updateMaterialAndPlace(oldPlaceAndMaterial);

Loading…
Cancel
Save