|
|
|
@ -122,7 +122,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 根据物料id查询物料
|
|
|
|
Material material = materialMapper.findMaterialById(mid); |
|
|
|
// 判断剩余容量是否可以存入
|
|
|
|
if (depositoryRecordById.getMaxNumber() - Inventory < quantity) { |
|
|
|
if (depositoryRecordById.getMaxNumber() - (double) (Inventory / 100) < quantity) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
// 获取当前填写的生产日期
|
|
|
|
@ -182,6 +182,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 如果不包含标志位.
|
|
|
|
map.put("flagForGroup", 1); |
|
|
|
} |
|
|
|
// 修改入库数量扩大100倍
|
|
|
|
map.put("quantity", ObjectFormatUtil.toDouble(map.get("quantity")) * 100); |
|
|
|
return depositoryRecordMapper.insertApplicationInRecord(map); |
|
|
|
} |
|
|
|
|
|
|
|
@ -203,7 +205,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (materialByCondition.size() > 0) { // 如果当前存在
|
|
|
|
Inventory mt = materialByCondition.get(0); |
|
|
|
map.put("mid", mt.getMid()); |
|
|
|
mt.setQuantity((int) (mt.getQuantity() + quantity)); |
|
|
|
mt.setQuantity((int) (mt.getQuantity() + quantity * 100)); |
|
|
|
mt.setProducedDate(producedDate); |
|
|
|
materialMapper.updateInventory(mt); |
|
|
|
newMid = mt.getId(); |
|
|
|
@ -211,7 +213,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Map<String, Object> insert = new HashMap<>(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
insert.put("depositoryId", depositoryId); |
|
|
|
insert.put("quantity", quantity); |
|
|
|
insert.put("quantity", quantity * 100); |
|
|
|
insert.put("shelfLife", materialById.getShelfLife()); |
|
|
|
insert.put("producedDate", producedDate); |
|
|
|
insert.put("mid", map.get("mid")); |
|
|
|
@ -402,24 +404,24 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
mapForYesterday.put("list", list); |
|
|
|
|
|
|
|
// 查询今天目前为止的入库
|
|
|
|
List<ApplicationInRecordP> applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday); |
|
|
|
List<ApplicationInRecord> applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday); |
|
|
|
|
|
|
|
// 查询昨天的入库
|
|
|
|
List<ApplicationInRecordP> applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday); |
|
|
|
List<ApplicationInRecord> applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday); |
|
|
|
// 今天的入库数量
|
|
|
|
int sumForToday = 0; |
|
|
|
double sumForToday = 0; |
|
|
|
// 今天的入库额度
|
|
|
|
double priceForToday = 0.0; |
|
|
|
// 昨天的入库数量
|
|
|
|
int sumForYesterDay = 0; |
|
|
|
double sumForYesterDay = 0; |
|
|
|
// 昨天的入库额度
|
|
|
|
double priceForYesterDay = 0.0; |
|
|
|
for (ApplicationInRecordP applicationInRecordP : applicationInRecordPForToday) { |
|
|
|
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) { |
|
|
|
// 获取当前入库类型(1物料2组合)
|
|
|
|
Integer flagForGroup = applicationInRecordP.getFlagForGroup(); |
|
|
|
sumForToday += applicationInRecordP.getQuantity(); |
|
|
|
sumForToday += (double)applicationInRecordP.getQuantity() / 100; |
|
|
|
if (applicationInRecordP.getPrice() != null) { |
|
|
|
priceForToday += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); |
|
|
|
priceForToday += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100); |
|
|
|
} else { |
|
|
|
priceForToday += 0; |
|
|
|
} |
|
|
|
@ -427,24 +429,23 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < applicationInRecordPForYesterday.size(); i++) { |
|
|
|
ApplicationInRecordP applicationInRecordP = applicationInRecordPForYesterday.get(i); |
|
|
|
sumForYesterDay += applicationInRecordP.getQuantity(); |
|
|
|
for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) { |
|
|
|
sumForYesterDay += (double)applicationInRecordP.getQuantity() / 100; |
|
|
|
if (applicationInRecordP.getPrice() != null) { |
|
|
|
priceForYesterDay += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); |
|
|
|
priceForYesterDay += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100); |
|
|
|
} else { |
|
|
|
priceForYesterDay += 0; |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("total", sumForToday); |
|
|
|
Double ratioForCount = 0.0; |
|
|
|
Double ratioForPrice = 0.0; |
|
|
|
double ratioForCount = 0.0; |
|
|
|
double ratioForPrice = 0.0; |
|
|
|
if (Double.compare(sumForYesterDay, 0.0) != 0) { |
|
|
|
ratioForCount = ((sumForToday - sumForYesterDay) / Double.parseDouble(Integer.toString(sumForYesterDay))); |
|
|
|
ratioForCount = ((sumForToday - sumForYesterDay) / sumForYesterDay); |
|
|
|
} |
|
|
|
if (Double.compare(priceForYesterDay, 0.0) != 0) { |
|
|
|
ratioForPrice = (priceForToday - priceForYesterDay) / Double.parseDouble(Double.toString(priceForYesterDay)); |
|
|
|
ratioForPrice = (priceForToday - priceForYesterDay) / priceForYesterDay; |
|
|
|
} |
|
|
|
BigDecimal bgForSum = new BigDecimal(ratioForCount); |
|
|
|
BigDecimal bgForPrice = new BigDecimal(ratioForPrice); |
|
|
|
@ -652,12 +653,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (placeId == null) { |
|
|
|
placeId = 0; |
|
|
|
} |
|
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
// 获取当前物料基本信息
|
|
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
map.put("mtId",materialById.getMaterialTypeId()); |
|
|
|
map.put("mtId", materialById.getMaterialTypeId()); |
|
|
|
String unit = (String) map.get("unit"); |
|
|
|
if ("-1".equals(unit)) { |
|
|
|
map.put("unit", materialById.getUnit()); |
|
|
|
@ -709,7 +710,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
* @param placeById 入库库位 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
Integer updateInventoryInfoForApproval(Map<String, Object> map, Integer quantity, Material materialById, Place placeById) { |
|
|
|
Integer updateInventoryInfoForApproval(Map<String, Object> map, double quantity, Material materialById, Place placeById) { |
|
|
|
// 获取当前入库的物料id
|
|
|
|
Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid")); |
|
|
|
// 获取当前入库记录id
|
|
|
|
@ -731,13 +732,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate); |
|
|
|
if (materialAndProducedDateByMidAndProducedDate != null) { |
|
|
|
// 增加当前数量
|
|
|
|
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + quantity); |
|
|
|
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity); |
|
|
|
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + (int) quantity * 100); |
|
|
|
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + (int) quantity * 100); |
|
|
|
// 修改
|
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate); |
|
|
|
} else { |
|
|
|
insertProducedDate.put("quantity", quantity); |
|
|
|
insertProducedDate.put("inventory", quantity); |
|
|
|
insertProducedDate.put("quantity", quantity * 100); |
|
|
|
insertProducedDate.put("inventory", quantity * 100); |
|
|
|
insertProducedDate.put("expendnum", 0); |
|
|
|
insertProducedDate.put("barCode", map.get("barCode")); |
|
|
|
insertProducedDate.put("qrCode", map.get("qrCode")); |
|
|
|
@ -765,16 +766,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(insert); |
|
|
|
if (placeAndMaterialByMidAndPid == null) { |
|
|
|
// 如果没有当前记录
|
|
|
|
insert.put("quantity", quantity); |
|
|
|
insert.put("quantity", quantity * 100); |
|
|
|
// 插入记录
|
|
|
|
placeMapper.addMaterialOnPlace(insert); |
|
|
|
} else { |
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity); |
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) quantity * 100); |
|
|
|
// 修改数量
|
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
} |
|
|
|
// 修改当前库位数量
|
|
|
|
placeById.setQuantity(placeById.getQuantity() + quantity); |
|
|
|
placeById.setQuantity(placeById.getQuantity() + (int) quantity * 100); |
|
|
|
return placeMapper.UpdatePlace(placeById); |
|
|
|
} |
|
|
|
|
|
|
|
@ -813,7 +814,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 将库存还原
|
|
|
|
Material material = materialByCondition.get(0); |
|
|
|
Map<String, Object> update = new HashMap<>(); |
|
|
|
update.put("quantity", material.getQuantity() - quantity); |
|
|
|
update.put("quantity", material.getQuantity() - quantity * 100); |
|
|
|
update.put("price", oldPrice); |
|
|
|
update.put("amounts", material.getAmounts() - quantity * price); |
|
|
|
update.put("id", material.getId()); |
|
|
|
@ -1053,8 +1054,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果是拆单后的出库
|
|
|
|
|
|
|
|
// 用于获取对应的拆单记录
|
|
|
|
@ -1115,8 +1115,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果不能满足需求
|
|
|
|
|
|
|
|
// 获取对应的拆单记录
|
|
|
|
@ -1160,8 +1159,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果当前拆单没有父级
|
|
|
|
|
|
|
|
|
|
|
|
@ -1246,8 +1244,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果大于
|
|
|
|
|
|
|
|
// 获取库存重要减少的数量
|
|
|
|
@ -1330,8 +1327,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果拆单库存处理记录不存在
|
|
|
|
|
|
|
|
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
@ -1397,8 +1393,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
@ -2096,57 +2091,57 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (!"".equals(sid) && flagForIn) { |
|
|
|
Integer id = ObjectFormatUtil.toInteger(sid.trim()); |
|
|
|
// 获取具体入库订单
|
|
|
|
ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
ApplicationInRecord record = depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
|
|
|
|
if (Integer.compare(recordP.getAirapproverPass(), 1) == 0) { |
|
|
|
if (Integer.compare(record.getAirapproverPass(), 1) == 0) { |
|
|
|
// 如果当前入库单已经被处理过,则跳过
|
|
|
|
continue; |
|
|
|
} |
|
|
|
// 获取当前入库对应的物料
|
|
|
|
Material materialById = materialMapper.findMaterialById(recordP.getMid()); |
|
|
|
Material materialById = materialMapper.findMaterialById(record.getMid()); |
|
|
|
|
|
|
|
if (recordP.getAirtoGroupId() != null) { |
|
|
|
if (record.getAirtoGroupId() != null) { |
|
|
|
// 如果该申请是组合入库下的申请
|
|
|
|
flagForGroupInfoInDepository = true; |
|
|
|
} |
|
|
|
// 用于调用入库方法而创建的
|
|
|
|
Map<String, Object> paramForUpdateInventory = new HashMap<>(); |
|
|
|
paramForUpdateInventory.put("mid", recordP.getMid()); |
|
|
|
paramForUpdateInventory.put("quantity", recordP.getQuantity()); |
|
|
|
paramForUpdateInventory.put("depositoryId", recordP.getDepositoryId()); |
|
|
|
paramForUpdateInventory.put("placeId", recordP.getPlaceId()); |
|
|
|
if (materialById.getUnit().equals(recordP.getAirUnit())) { |
|
|
|
paramForUpdateInventory.put("mid", record.getMid()); |
|
|
|
paramForUpdateInventory.put("quantity", record.getQuantity()); |
|
|
|
paramForUpdateInventory.put("depositoryId", record.getDepositoryId()); |
|
|
|
paramForUpdateInventory.put("placeId", record.getPlaceId()); |
|
|
|
if (materialById.getUnit().equals(record.getAirUnit())) { |
|
|
|
// 如果是基础单位
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId", recordP.getDepositoryId()); |
|
|
|
param.put("depositoryId", record.getDepositoryId()); |
|
|
|
param.put("mcode", materialById.getCode()); |
|
|
|
// 判断该仓库中有无该物物料
|
|
|
|
List<Inventory> materialByCondition = materialMapper.findInventory(param); |
|
|
|
|
|
|
|
|
|
|
|
// 修改仓库库存
|
|
|
|
Long mproducedDate = recordP.getMproducedDate(); |
|
|
|
Long mproducedDate = record.getMproducedDate(); |
|
|
|
if (mproducedDate == null) { |
|
|
|
mproducedDate = 0L; |
|
|
|
} |
|
|
|
// 获取当前库存id
|
|
|
|
Integer newMid = updateOrInsertInventory(paramForUpdateInventory, materialByCondition, (double) recordP.getQuantity(), materialById.getId(), recordP.getDepositoryId(), mproducedDate); |
|
|
|
Integer newMid = updateOrInsertInventory(paramForUpdateInventory, materialByCondition, (double) record.getQuantity(), materialById.getId(), record.getDepositoryId(), mproducedDate); |
|
|
|
// 修改库位库存
|
|
|
|
paramForUpdateInventory.put("newInMid", newMid); |
|
|
|
paramForUpdateInventory.put("id", recordP.getId()); |
|
|
|
paramForUpdateInventory.put("producedDate", recordP.getMproducedDate()); |
|
|
|
Place placeById = placeMapper.findPlaceById(recordP.getPlaceId()); |
|
|
|
paramForUpdateInventory.put("id", record.getId()); |
|
|
|
paramForUpdateInventory.put("producedDate", record.getMproducedDate()); |
|
|
|
Place placeById = placeMapper.findPlaceById(record.getPlaceId()); |
|
|
|
// 修改当前库存容量
|
|
|
|
updateInventoryInfoForApproval(paramForUpdateInventory, recordP.getQuantity(), materialById, placeById); |
|
|
|
updateInventoryInfoForApproval(paramForUpdateInventory, record.getQuantity(), materialById, placeById); |
|
|
|
} else { |
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
// 查询拆单记录
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", recordP.getAirUnit()); |
|
|
|
paramForSplitInfo.put("mid", recordP.getMid()); |
|
|
|
paramForSplitInfo.put("newUnit", record.getAirUnit()); |
|
|
|
paramForSplitInfo.put("mid", record.getMid()); |
|
|
|
// 查询当前拆单是否存在
|
|
|
|
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
if (splitInfoForUnit != null) { |
|
|
|
@ -2163,8 +2158,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId()); |
|
|
|
|
|
|
|
Map<String, Object> paramForInventory = new HashMap<>(); |
|
|
|
paramForInventory.put("depositoryId", recordP.getDepositoryId()); |
|
|
|
paramForInventory.put("mid", recordP.getMid()); |
|
|
|
paramForInventory.put("depositoryId", record.getDepositoryId()); |
|
|
|
paramForInventory.put("mid", record.getMid()); |
|
|
|
// 判断该仓库中有无该物物料
|
|
|
|
List<Inventory> inventoryList = materialMapper.findInventory(paramForInventory); |
|
|
|
|
|
|
|
@ -2173,7 +2168,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
// 用于查找该库存对应库位
|
|
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
|
paramForInventoryToPlace.put("pid", recordP.getPlaceId()); |
|
|
|
paramForInventoryToPlace.put("pid", record.getPlaceId()); |
|
|
|
paramForInventoryToPlace.put("mid", inventory.getId()); |
|
|
|
|
|
|
|
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace); |
|
|
|
@ -2184,7 +2179,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory); |
|
|
|
} |
|
|
|
} |
|
|
|
splitUnitService.realInInventoryToDepository((double) recordP.getQuantity(), splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true); |
|
|
|
splitUnitService.realInInventoryToDepository((double) record.getQuantity(), splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true); |
|
|
|
if (paramForUpdateInventory.containsKey("applicationInId")) { |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateInventory.get("applicationInId"))); |
|
|
|
} |
|
|
|
@ -2609,7 +2604,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
|
|
|
|
// 获取具体入库订单
|
|
|
|
ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); |
|
|
|
ApplicationInRecord recordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前入库对应的物料
|
|
|
|
@ -3384,23 +3379,26 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
String applyTime = (String) map.get("applyTime"); |
|
|
|
map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime)); |
|
|
|
} |
|
|
|
List<ApplicationInRecordP> list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); |
|
|
|
for (ApplicationInRecordP applicationInRecordP : list) { |
|
|
|
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userToken); |
|
|
|
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); |
|
|
|
applicationInRecordP.setApplicantName(userByPortById.getName()); |
|
|
|
applicationInRecordP.setApplicantTime(time); |
|
|
|
applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); |
|
|
|
if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { |
|
|
|
List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); |
|
|
|
List<ApplicationInRecordP> result = new ArrayList<>(); |
|
|
|
|
|
|
|
for (ApplicationInRecord applicationInRecord : list) { |
|
|
|
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userToken); |
|
|
|
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); |
|
|
|
applicationInRecord.setApplicantName(userByPortById.getName()); |
|
|
|
applicationInRecord.setApplicantTime(time); |
|
|
|
applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark()); |
|
|
|
if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) { |
|
|
|
// 如果入库的是组合
|
|
|
|
Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); |
|
|
|
applicationInRecordP.setMname(group.getGname()); |
|
|
|
applicationInRecordP.setAirUnit(""); |
|
|
|
applicationInRecordP.setMcode(group.getCode()); |
|
|
|
applicationInRecordP.setMversion("组合"); |
|
|
|
Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid()); |
|
|
|
applicationInRecord.setMname(group.getGname()); |
|
|
|
applicationInRecord.setAirUnit(""); |
|
|
|
applicationInRecord.setMcode(group.getCode()); |
|
|
|
applicationInRecord.setMversion("组合"); |
|
|
|
} |
|
|
|
ApplicationInRecordP ap = new ApplicationInRecordP(); |
|
|
|
} |
|
|
|
return list; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -3440,24 +3438,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
map.put("depositoryIdList", depositoryIdList); |
|
|
|
map.put("applicantId", userByPort.getId()); |
|
|
|
List<ApplicationInRecordP> list = depositoryRecordMapper.findApplicationInRecordPByUser(map); |
|
|
|
for (ApplicationInRecordP applicationInRecordP : list) { |
|
|
|
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userByPort); |
|
|
|
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); |
|
|
|
applicationInRecordP.setApplicantName(userByPortById.getName()); |
|
|
|
applicationInRecordP.setApplicantTime(time); |
|
|
|
applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); |
|
|
|
if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { |
|
|
|
List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByUser(map); |
|
|
|
List<ApplicationInRecordP> result = new ArrayList<>(); |
|
|
|
for (ApplicationInRecord applicationInRecord : list) { |
|
|
|
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userByPort); |
|
|
|
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); |
|
|
|
applicationInRecord.setApplicantName(userByPortById.getName()); |
|
|
|
applicationInRecord.setApplicantTime(time); |
|
|
|
applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark()); |
|
|
|
if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) { |
|
|
|
// 如果入库的是组合
|
|
|
|
Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); |
|
|
|
applicationInRecordP.setMname(group.getGname()); |
|
|
|
applicationInRecordP.setAirUnit(""); |
|
|
|
applicationInRecordP.setMcode(group.getCode()); |
|
|
|
applicationInRecordP.setMversion("组合"); |
|
|
|
Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid()); |
|
|
|
applicationInRecord.setMname(group.getGname()); |
|
|
|
applicationInRecord.setAirUnit(""); |
|
|
|
applicationInRecord.setMcode(group.getCode()); |
|
|
|
applicationInRecord.setMversion("组合"); |
|
|
|
} |
|
|
|
ApplicationInRecordP arp = new ApplicationInRecordP(applicationInRecord); |
|
|
|
result.add(arp); |
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -3584,7 +3585,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ApplicationInRecordP> findApplicationInRecordByDepository(String depositoryId) { |
|
|
|
return depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId); |
|
|
|
List<ApplicationInRecord> recordByDepository = depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId); |
|
|
|
List<ApplicationInRecordP> list = new ArrayList<>(); |
|
|
|
for (ApplicationInRecord record:recordByDepository |
|
|
|
) { |
|
|
|
ApplicationInRecordP recordP = new ApplicationInRecordP(record); |
|
|
|
list.add(recordP); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -3808,17 +3816,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Override |
|
|
|
public Map<String, Object> CalculateAllApplicationInAll(List<Integer> list) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
List<ApplicationInRecordP> applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list); |
|
|
|
Double sum = 0.0; |
|
|
|
Integer count = 0; |
|
|
|
for (int i = 0; i < applicationInRecordPAll.size(); i++) { |
|
|
|
ApplicationInRecordP applicationInRecordP = applicationInRecordPAll.get(i); |
|
|
|
List<ApplicationInRecord> applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list); |
|
|
|
double sum = 0.0; |
|
|
|
double count = 0; |
|
|
|
for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) { |
|
|
|
double price = 0.0; |
|
|
|
if (applicationInRecordP.getPrice() != null) { |
|
|
|
price = applicationInRecordP.getPrice(); |
|
|
|
} |
|
|
|
sum += price * applicationInRecordP.getQuantity() / 100; |
|
|
|
count += applicationInRecordP.getQuantity(); |
|
|
|
sum += price * applicationInRecordP.getQuantity() / 10000; |
|
|
|
count += (double)applicationInRecordP.getQuantity() / 100; |
|
|
|
} |
|
|
|
BigDecimal bg = new BigDecimal(sum); |
|
|
|
sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
@ -3836,17 +3843,15 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Override |
|
|
|
public Double CalculateAllApplicationOutPrice(String state) { |
|
|
|
List<ApplicationOutRecordP> applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll(); |
|
|
|
Double sum = 0.0; |
|
|
|
double sum = 0.0; |
|
|
|
if (state.isEmpty()) { |
|
|
|
// 如果要获取所有待出库的金额
|
|
|
|
for (int i = 0; i < applicationOutRecordPAll.size(); i++) { |
|
|
|
ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); |
|
|
|
for (ApplicationOutRecordP applicationOutRecordP : applicationOutRecordPAll) { |
|
|
|
// 获取所有子物料
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("parentId", applicationOutRecordP.getId()); |
|
|
|
List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); |
|
|
|
for (int k = 0; k < minByCondition.size(); k++) { |
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); |
|
|
|
for (ApplicationOutRecordMin applicationOutRecordMin : minByCondition) { |
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
if (materialById.getPrice() != null) { |
|
|
|
@ -3911,16 +3916,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) { |
|
|
|
public Double findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("start", start); |
|
|
|
map.put("end", end); |
|
|
|
map.put("depositoryId", depositoryId); |
|
|
|
double quantity = 0.0; |
|
|
|
if (type == 1) { |
|
|
|
return depositoryRecordMapper.findApplicationInRecordByDate(map); |
|
|
|
quantity = (double) depositoryRecordMapper.findApplicationInRecordByDate(map) / 100; |
|
|
|
return quantity; |
|
|
|
} else { |
|
|
|
map.put("state", "已出库"); |
|
|
|
return depositoryRecordMapper.findApplicationOutRecordByDate(map); |
|
|
|
quantity = (double) depositoryRecordMapper.findApplicationOutRecordByDate(map); |
|
|
|
return quantity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -4003,7 +4011,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer findMaterialCountByMonth2(Map<String, Object> map) { |
|
|
|
public Double findMaterialCountByMonth2(Map<String, Object> map) { |
|
|
|
Integer type = ObjectFormatUtil.toInteger(map.get("type")); |
|
|
|
Object o = map.get("oldId"); |
|
|
|
List<Long> allMtByParent = null; |
|
|
|
@ -4013,10 +4021,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
allMtByParent = findChildForMaterialTypeByParent(mt); |
|
|
|
map.put("list", allMtByParent); |
|
|
|
} |
|
|
|
Integer sumCount = 0; |
|
|
|
double sumCount = 0; |
|
|
|
if (type == 1) { |
|
|
|
// 如果入库
|
|
|
|
sumCount = depositoryRecordMapper.findApplicationInByMonthTest(map); |
|
|
|
sumCount = (double)depositoryRecordMapper.findApplicationInByMonthTest(map) / 100; |
|
|
|
} else { |
|
|
|
// 如果出库
|
|
|
|
sumCount = depositoryRecordMapper.findApplicationOutByMonth(map); |
|
|
|
@ -4042,7 +4050,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ApplicationInRecordP findApplicationInRecordPById(Integer id) { |
|
|
|
return depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
ApplicationInRecord applicationInRecordPById = depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
return new ApplicationInRecordP(applicationInRecordPById); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -4053,7 +4062,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent) { |
|
|
|
ApplicationInRecordP record = depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
ApplicationInRecord record = depositoryRecordMapper.findApplicationInRecordPById(id); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
@ -4074,11 +4083,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer deleteApplicationInRecordByIds(List<Integer> list, UserByPort userToken, String userAgent) { |
|
|
|
List<ApplicationInRecordP> applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list); |
|
|
|
List<ApplicationInRecord> applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
for (ApplicationInRecordP record : applicationInRecordsByIds |
|
|
|
for (ApplicationInRecord record : applicationInRecordsByIds |
|
|
|
) { |
|
|
|
if (Integer.compare(record.getAirapproverPass(), 4) == 0 || Integer.compare(record.getAirapproverPass(), 1) == 0) { |
|
|
|
updateInventoryForErrorInRecord(record.getMid(), record.getQuantity(), record.getAirUnit(), record.getPlaceId(), record.getDepositoryId()); |
|
|
|
@ -4126,15 +4135,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 修改当前库存记录
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - quantity, 0)); |
|
|
|
place.setQuantity(Math.max(place.getQuantity() - quantity, 0)); |
|
|
|
inventory.setQuantity(Math.max(inventory.getQuantity() - quantity,0)); |
|
|
|
inventory.setQuantity(Math.max(inventory.getQuantity() - quantity, 0)); |
|
|
|
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
placeMapper.UpdatePlace(place); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果不是基础单位
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
@ -4156,7 +4164,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (splitInventory.getSaveQuantity() >= quantity) { |
|
|
|
// 如果当前待处理数目可以满足需求
|
|
|
|
|
|
|
|
splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity,0)); |
|
|
|
splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity, 0)); |
|
|
|
|
|
|
|
// 修改库存处理记录
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
@ -4213,7 +4221,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (inventory.getQuantity() >= 1 && flag) { |
|
|
|
|
|
|
|
// 令库存-1
|
|
|
|
inventory.setQuantity(Math.max(inventory.getQuantity() - 1,0)); |
|
|
|
inventory.setQuantity(Math.max(inventory.getQuantity() - 1, 0)); |
|
|
|
|
|
|
|
|
|
|
|
// 修改库存记录
|
|
|
|
@ -4221,12 +4229,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
|
|
|
|
// 修改当前库位存放物料的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1,0)); |
|
|
|
placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1, 0)); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
// 修改库位数量
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
placeById.setQuantity(Math.max(placeById.getQuantity() - 1,0)); |
|
|
|
placeById.setQuantity(Math.max(placeById.getQuantity() - 1, 0)); |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
|
|
|
|
|
|
|
|
@ -4237,8 +4245,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + quantity); |
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果大于
|
|
|
|
|
|
|
|
// 获取库存重要减少的数量
|
|
|
|
|