Browse Source

修改仓储中心提交出库申请时由自己审批

lwx_dev
erdanergou 3 years ago
parent
commit
2a255c7c62
  1. 134
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  2. 1
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

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

@ -419,23 +419,44 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
double priceForYesterDay = 0.0; double priceForYesterDay = 0.0;
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) {
// 获取当前入库类型(1物料2组合) // 获取当前入库类型(1物料2组合)
Integer flagForGroup = applicationInRecordP.getFlagForGroup();
sumForToday += (double) applicationInRecordP.getQuantity() / 100; sumForToday += (double) applicationInRecordP.getQuantity() / 100;
if (applicationInRecordP.getPrice() != null) {
priceForToday += applicationInRecordP.getPrice() * (double) (applicationInRecordP.getQuantity() / 100); Integer mid = applicationInRecordP.getMid();
} else { Material materialById = materialMapper.findMaterialById(mid);
if (materialById.getPrice() != null) {
priceForToday += 0; priceForToday += 0;
} else {
if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) {
priceForToday += materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100;
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit());
paramForSplitInfo.put("mid", mid);
SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1);
priceForToday += materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100;
}
} }
} }
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) {
sumForYesterDay += (double) applicationInRecordP.getQuantity() / 100; sumForYesterDay += (double) applicationInRecordP.getQuantity() / 100;
if (applicationInRecordP.getPrice() != null) { Integer mid = applicationInRecordP.getMid();
priceForYesterDay += applicationInRecordP.getPrice() * (double) (applicationInRecordP.getQuantity() / 100); Material materialById = materialMapper.findMaterialById(mid);
} else { if (materialById.getPrice() != null) {
priceForYesterDay += 0; priceForYesterDay += 0;
} else {
if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) {
priceForYesterDay += materialById.getPrice() * (double) applicationInRecordP.getQuantity() / 100;
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit());
paramForSplitInfo.put("mid", mid);
SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1);
priceForYesterDay += materialById.getPrice() / scale * (double) applicationInRecordP.getQuantity() / 100;
}
} }
} }
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
@ -536,7 +557,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} catch (ExecutionException e) { } catch (ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }
countForToday += ObjectFormatUtil.toInteger(((Map<String, Object>) o).get("count")); countForToday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("count"));
priceForToday += Double.parseDouble(((Map<String, Object>) o).get("price").toString()); priceForToday += Double.parseDouble(((Map<String, Object>) o).get("price").toString());
} }
} }
@ -592,25 +613,55 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationOutRecordMin> applicationOutMinForCompleteForToday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForToday); List<ApplicationOutRecordMin> applicationOutMinForCompleteForToday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForToday);
// 如果获取已经出库的数量(昨天) // 如果获取已经出库的数量(昨天)
List<ApplicationOutRecordMin> applicationOutMinForCompleteForYesterday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForYesterday); List<ApplicationOutRecordMin> applicationOutMinForCompleteForYesterday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForYesterday);
for (int i = 0; i < applicationOutMinForCompleteForToday.size(); i++) { for (ApplicationOutRecordMin recordMin : applicationOutMinForCompleteForToday) {
ApplicationOutRecordMin recordMin = applicationOutMinForCompleteForToday.get(i); countForToday += (double) recordMin.getQuantity() / 100.0;
countForToday += recordMin.getQuantity();
// 获取当前出库物料 // 获取当前出库物料
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid()); Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 计算当前出库金额 double quantity = (double) recordMin.getQuantity() / 100.0;
double price_out = materialById.getPrice() * recordMin.getQuantity(); double price_out = 0.0;
if (recordMin.getUnit().equals(materialById.getUnit())) {
if (materialById.getPrice() != null) {
price_out = materialById.getPrice() * quantity;
}
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", recordMin.getUnit());
paramForSplitInfo.put("mid", materialById.getMid());
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
if (materialById.getPrice() != null) {
price_out = materialById.getPrice() / scale * quantity;
}
}
BigDecimal bg = new BigDecimal(price_out / 100); BigDecimal bg = new BigDecimal(price_out / 100);
price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
priceForToday += price_out; priceForToday += price_out;
} }
for (int i = 0; i < applicationOutMinForCompleteForYesterday.size(); i++) { for (ApplicationOutRecordMin recordMin : applicationOutMinForCompleteForYesterday) {
ApplicationOutRecordMin recordMin = applicationOutMinForCompleteForYesterday.get(i); countForYesterday += (double) recordMin.getQuantity() / 100.0;
countForYesterday += recordMin.getQuantity();
// 获取当前出库物料 // 获取当前出库物料
Material materialById = materialMapper.findMaterialById(recordMin.getMid()); Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 计算当前出库金额 double quantity = (double) recordMin.getQuantity() / 100.0;
double price_out = materialById.getPrice() * recordMin.getQuantity(); double price_out = 0.0;
if (recordMin.getUnit().equals(materialById.getUnit())) {
if (materialById.getPrice() != null) {
price_out = materialById.getPrice() * quantity;
}
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", recordMin.getUnit());
paramForSplitInfo.put("mid", materialById.getMid());
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
if (materialById.getPrice() != null) {
price_out = materialById.getPrice() / scale * quantity;
}
}
BigDecimal bg = new BigDecimal(price_out / 100); BigDecimal bg = new BigDecimal(price_out / 100);
price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
priceForYesterday += price_out; priceForYesterday += price_out;
@ -1394,7 +1445,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insertForSplitInventory.put("flagForApproval", false); insertForSplitInventory.put("flagForApproval", false);
splitUnitService.addSplitInventory(insertForSplitInventory); splitUnitService.addSplitInventory(insertForSplitInventory);
Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid")); Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("applicationInIdForOut"));
depositoryRecordMapper.deleteApplicationInRecordById(new_id); depositoryRecordMapper.deleteApplicationInRecordById(new_id);
@ -3042,7 +3093,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果当前入库的数量大于拆单规定的进制数量 // 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目 // 计算要进的数目
int quantity_in = (int)(realQuantity / splitInfo.getQuantity()); int quantity_in = (int) (realQuantity / splitInfo.getQuantity());
// 更新处理数量 // 更新处理数量
disposeQuantity += quantity_in; disposeQuantity += quantity_in;
// 拆单库存实际入库的数量 // 拆单库存实际入库的数量
@ -3078,7 +3129,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} else { } else {
applicationInPlace(map, true); applicationInPlace(map, true);
// map.put("applicationInId", map.get("id")); // map.put("applicationInId", map.get("id"));
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("applicationInId")));
// map.remove("id"); // map.remove("id");
} }
@ -3118,7 +3169,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果当前入库的数量大于拆单规定的进制数量 // 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目 // 计算要进的数目
int quantity_in = (int)(realQuantity / splitInfo.getQuantity()); int quantity_in = (int) (realQuantity / splitInfo.getQuantity());
// 更新处理数量 // 更新处理数量
disposeQuantity += quantity_in; disposeQuantity += quantity_in;
// 拆单库存实际入库的数量 // 拆单库存实际入库的数量
@ -3281,7 +3332,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果当前入库的数量大于拆单规定的进制数量 // 如果当前入库的数量大于拆单规定的进制数量
// 计算要进的数目 // 计算要进的数目
int quantity_in = (int)(realQuantity / splitInfo.getQuantity()); int quantity_in = (int) (realQuantity / splitInfo.getQuantity());
// 更新处理数量 // 更新处理数量
disposeQuantity += quantity_in; disposeQuantity += quantity_in;
// 拆单库存实际入库的数量 // 拆单库存实际入库的数量
@ -3857,11 +3908,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
double sum = 0.0; double sum = 0.0;
double count = 0; double count = 0;
for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) {
double price = 0.0; Material materialById = materialMapper.findMaterialById(applicationInRecordP.getMid());
if (applicationInRecordP.getPrice() != null) { if ("-1".equals(applicationInRecordP.getAirUnit()) || materialById.getUnit().equals(applicationInRecordP.getAirUnit())) {
price = applicationInRecordP.getPrice(); sum += materialById.getPrice() / 100 * (double) applicationInRecordP.getQuantity() / 100;
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", applicationInRecordP.getAirUnit());
paramForSplitInfo.put("mid", applicationInRecordP.getMid());
SplitInfo splitInfoByMidAndUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfoByMidAndUnit, -1);
sum += materialById.getPrice() / scale / 100 * (double) applicationInRecordP.getQuantity() / 100;
} }
sum += price * applicationInRecordP.getQuantity() / 10000;
count += (double) applicationInRecordP.getQuantity() / 100; count += (double) applicationInRecordP.getQuantity() / 100;
} }
BigDecimal bg = new BigDecimal(sum); BigDecimal bg = new BigDecimal(sum);
@ -4385,7 +4442,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid()); insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid());
insertForSplitInventory.put("type", "in"); insertForSplitInventory.put("type", "in");
splitUnitService.addSplitInventory(insertForSplitInventory); splitUnitService.addSplitInventory(insertForSplitInventory);
Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid")); Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("applicationInId"));
depositoryRecordMapper.deleteApplicationInRecordById(new_id); depositoryRecordMapper.deleteApplicationInRecordById(new_id);
} }
} }
@ -4601,9 +4658,22 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid()); Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 计算当前出库金额 // 计算当前出库金额
double price_out = 0.0; double price_out = 0.0;
if (materialById.getPrice() != null) { if (recordMin.getUnit().equals(materialById.getUnit())) {
price_out = materialById.getPrice() * quantity; if (materialById.getPrice() != null) {
price_out = materialById.getPrice() * quantity;
}
} else {
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", recordMin.getUnit());
paramForSplitInfo.put("mid", materialById.getMid());
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
if (materialById.getPrice() != null) {
price_out = materialById.getPrice() / scale * quantity;
}
} }
BigDecimal bg = new BigDecimal(price_out / 100); BigDecimal bg = new BigDecimal(price_out / 100);
price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
price += price_out; price += price_out;

1
src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

@ -172,6 +172,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
if ("in".equals(type) && !flagForApproval) { if ("in".equals(type) && !flagForApproval) {
// 如果是入库并且不需要审批 // 如果是入库并且不需要审批
result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid, false); result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid, false);
map.put("applicationInIdForOut",map.get("applicationInId"));
map.remove("applicationInId"); map.remove("applicationInId");
} else if ("in".equals(type)) { } else if ("in".equals(type)) {
// 如果是入库且需要审批 // 如果是入库且需要审批

Loading…
Cancel
Save