|
|
|
@ -722,7 +722,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
flagForApproval = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if(map.containsKey("isGroup")){ |
|
|
|
if (map.containsKey("isGroup")) { |
|
|
|
flagForApproval = isApprovalPass; |
|
|
|
} |
|
|
|
map.put("flagForApproval", flagForApproval); |
|
|
|
@ -1120,14 +1120,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果是拆单后的出库
|
|
|
|
|
|
|
|
// 用于获取对应的拆单记录
|
|
|
|
@ -1191,8 +1189,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果不能满足需求
|
|
|
|
|
|
|
|
// 获取对应的拆单记录
|
|
|
|
@ -1218,7 +1215,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前父级拆单记录
|
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoById.getParentId()); |
|
|
|
|
|
|
|
@ -1235,17 +1231,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("unit", applicationOutMinById.getUnit()); |
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
trueOut = 0.0; |
|
|
|
splitInventory.setSaveQuantity((int)(oldSplitInventory * 100)); |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() - (int)(oldSplitInventory * 100)); |
|
|
|
splitInventory.setSaveQuantity((int) (oldSplitInventory * 100)); |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() - (int) (oldSplitInventory * 100)); |
|
|
|
// 修改库存数量
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
} |
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果当前拆单没有父级
|
|
|
|
|
|
|
|
|
|
|
|
@ -1330,8 +1325,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果大于
|
|
|
|
|
|
|
|
// 获取库存重要减少的数量
|
|
|
|
@ -1365,8 +1359,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 如果当前库存中的物料库存不足以出库
|
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
restResponse.setStatus(566); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "当前位置未发现该物料")); |
|
|
|
@ -1420,8 +1413,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果拆单库存处理记录不存在
|
|
|
|
|
|
|
|
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
@ -1489,8 +1481,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
@ -1546,8 +1537,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果当前库存拆单记录的库存不能满足需要
|
|
|
|
|
|
|
|
@ -1621,8 +1611,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果当前当前父级与其的库存数量不大于要出库的数量
|
|
|
|
|
|
|
|
if (parentSplitInfo.getParentId() != null) { |
|
|
|
@ -1671,8 +1660,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} else { |
|
|
|
return restResponse1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果没有父级
|
|
|
|
|
|
|
|
// 获取当前拆单单位与顶级之间的进制
|
|
|
|
@ -1701,8 +1689,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
placeMapper.updateMaterialAndPlace(materialAndPlace); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果不可出库
|
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
@ -1711,8 +1698,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果已经没有父级
|
|
|
|
|
|
|
|
// 获取基础单位与当前实际出库单位单位之间的进制
|
|
|
|
@ -1723,23 +1709,23 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 获取对应的库存
|
|
|
|
Inventory inventory = materialMapper.findInventoryById(materialAndPlace.getMid()); |
|
|
|
|
|
|
|
if(surplus_redundant == 0) { |
|
|
|
if (surplus_redundant == 0) { |
|
|
|
surplus_redundant = 1; |
|
|
|
} |
|
|
|
// 设置当前库存数量
|
|
|
|
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - surplus_redundant * 100); |
|
|
|
inventory.setQuantity(inventory.getQuantity() - surplus_redundant * 100); |
|
|
|
// 设置当前库存数量
|
|
|
|
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - surplus_redundant * 100); |
|
|
|
inventory.setQuantity(inventory.getQuantity() - surplus_redundant * 100); |
|
|
|
|
|
|
|
|
|
|
|
// 修改库存数量
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
placeMapper.updateMaterialAndPlace(materialAndPlace); |
|
|
|
|
|
|
|
Map<String,Object> insertForOut = new HashMap<>(); |
|
|
|
insertForOut.put("unit",realSplitInfo.getNewUnit()); |
|
|
|
insertForOut.put("quantity",surplus_redundant * splitInfoScaleQuantityForAll - nowQuantity); |
|
|
|
insertForOut.put("placeId",materialAndPlace.getPid()); |
|
|
|
insertForOut.put("depositoryId",materialAndPlace.getDid()); |
|
|
|
Map<String, Object> insertForOut = new HashMap<>(); |
|
|
|
insertForOut.put("unit", realSplitInfo.getNewUnit()); |
|
|
|
insertForOut.put("quantity", surplus_redundant * splitInfoScaleQuantityForAll - nowQuantity); |
|
|
|
insertForOut.put("placeId", materialAndPlace.getPid()); |
|
|
|
insertForOut.put("depositoryId", materialAndPlace.getDid()); |
|
|
|
insertForOut.put("mid", inventory.getMid()); |
|
|
|
insertForOut.put("mcode", inventory.getCode()); |
|
|
|
insertForOut.put("type", "in"); |
|
|
|
@ -1751,8 +1737,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
restResponse.setData(surplus_redundant); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果不能满足需求
|
|
|
|
|
|
|
|
restResponse.setStatus(508); |
|
|
|
@ -1763,6 +1748,167 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于修改出库子记录 |
|
|
|
* |
|
|
|
* @param map 待修改数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer updateOutMinRecordInfo(Map<String, Object> map, UserByPort userToken, String userAgent) { |
|
|
|
Integer result = 0; |
|
|
|
|
|
|
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
|
|
|
// 获取更改的数量
|
|
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
|
|
|
|
|
// 获取出库子记录信息
|
|
|
|
ApplicationOutRecordMin outRecordMin = depositoryRecordMapper.findApplicationOutMinById(id); |
|
|
|
// 获取出库主记录
|
|
|
|
ApplicationOutRecord outRecord = depositoryRecordMapper.findApplicationOutRecordPById(outRecordMin.getParentId()); |
|
|
|
|
|
|
|
// 获取已出库的数量
|
|
|
|
Integer trueOut = outRecordMin.getTrueOut(); |
|
|
|
// 获取要出库的数量
|
|
|
|
Integer outQuantity = outRecordMin.getQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取出库的单位
|
|
|
|
String unit = outRecordMin.getUnit(); |
|
|
|
|
|
|
|
// 获取库存记录
|
|
|
|
Inventory inventoryById = materialMapper.findInventoryById(outRecordMin.getMid()); |
|
|
|
if (Integer.compare(trueOut, 0) != 0) { |
|
|
|
// 如果是开始出库的
|
|
|
|
|
|
|
|
if (trueOut >= (int) (quantity * 100)) { |
|
|
|
// 如果已经出库的数量大于要修改的数量
|
|
|
|
|
|
|
|
// 如果已经完成了出库
|
|
|
|
|
|
|
|
// 获取要退库的数量
|
|
|
|
double returnQuantity = (double) (trueOut / 100) - quantity; |
|
|
|
|
|
|
|
|
|
|
|
// 获取出库库位
|
|
|
|
Place placeById = placeMapper.findPlaceById(outRecordMin.getPlaceId()); |
|
|
|
|
|
|
|
// 用于获取映射关系
|
|
|
|
Map<String, Object> paramForPlaceAndMaterial = new HashMap<>(); |
|
|
|
paramForPlaceAndMaterial.put("mid", placeById.getId()); |
|
|
|
paramForPlaceAndMaterial.put("iid", inventoryById.getId()); |
|
|
|
// 获取库存与库存之间的映射
|
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForPlaceAndMaterial); |
|
|
|
|
|
|
|
|
|
|
|
if ("-1".equals(unit)) { |
|
|
|
// 如果是基础单位
|
|
|
|
|
|
|
|
|
|
|
|
// 设置库存数量
|
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() + (int) (returnQuantity * 100)); |
|
|
|
// 设置库位数量
|
|
|
|
placeById.setQuantity(placeById.getQuantity() + (int) (returnQuantity * 100)); |
|
|
|
// 设置新映射数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (returnQuantity * 100)); |
|
|
|
// 修改
|
|
|
|
materialMapper.updateInventory(inventoryById); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
} else { |
|
|
|
// 如果是拆单
|
|
|
|
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("mid", inventoryById.getMid()); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
// 获取拆单记录
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
|
paramForSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId()); |
|
|
|
// 获取拆单库存记录
|
|
|
|
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
|
|
|
|
|
Map<String, Object> paramForUpdateSplitInventory = new HashMap<>(); |
|
|
|
paramForUpdateSplitInventory.put("placeId", outRecordMin.getPlaceId()); |
|
|
|
paramForUpdateSplitInventory.put("depositoryId", outRecordMin.getDepositoryId()); |
|
|
|
paramForUpdateSplitInventory.put("quantity", returnQuantity); |
|
|
|
paramForUpdateSplitInventory.put("mid", inventoryById.getMid()); |
|
|
|
paramForUpdateSplitInventory.put("unit", unit); |
|
|
|
result = splitUnitService.realInInventoryToDepository(returnQuantity, splitInventory, paramForUpdateSplitInventory, splitInfo, placeAndMaterialByMidAndPid, false); |
|
|
|
if (paramForUpdateSplitInventory.containsKey("applicationInId")) { |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateSplitInventory.get("applicationInId"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 修改子单数据
|
|
|
|
outRecordMin.setQuantity((int) (quantity * 100)); |
|
|
|
outRecordMin.setTrueOut((int) (quantity * 100)); |
|
|
|
depositoryRecordMapper.updateApplicationOutRecordMin(outRecordMin); |
|
|
|
|
|
|
|
if (Integer.compare(trueOut, outQuantity) != 0) { |
|
|
|
//如果没有完成出库
|
|
|
|
|
|
|
|
// 强行完成出库
|
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, outRecordMin, outRecord, (double) (quantity / 100), userToken, placeById.getId(), userAgent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
// 如果不大于
|
|
|
|
// 设置新数量
|
|
|
|
outRecordMin.setQuantity((int) (quantity * 100)); |
|
|
|
// 修改记录
|
|
|
|
result = depositoryRecordMapper.updateApplicationOutRecordMin(outRecordMin); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 如果未开始出库的
|
|
|
|
|
|
|
|
// 设置新数量
|
|
|
|
outRecordMin.setQuantity((int) (quantity * 100)); |
|
|
|
// 修改记录
|
|
|
|
result = depositoryRecordMapper.updateApplicationOutRecordMin(outRecordMin); |
|
|
|
} |
|
|
|
|
|
|
|
// 修改主记录的出库数量
|
|
|
|
outRecord.setQuantity(outRecord.getQuantity() - outQuantity + (int) (quantity * 100)); |
|
|
|
if ("-1".equals(unit)) { |
|
|
|
// 如果是基础单位
|
|
|
|
if (inventoryById.getPrice() != null) { |
|
|
|
outRecord.setPrice(outRecord.getPrice() - inventoryById.getPrice() * (outQuantity / 100) + inventoryById.getPrice() * quantity); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
if (inventoryById.getPrice() != null) { |
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("mid", inventoryById.getMid()); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
// 获取拆单记录
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
// 获取当前拆单单位与基础单位的进制
|
|
|
|
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
|
|
|
|
double newPrice = inventoryById.getPrice() / splitInfoScaleQuantity; |
|
|
|
BigDecimal bg = new BigDecimal(newPrice); |
|
|
|
newPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
|
|
outRecord.setPrice(outRecord.getPrice() - (newPrice * (outQuantity / 100) ) + newPrice * quantity); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于完成出库时的相关处理操作 |
|
|
|
* |
|
|
|
@ -2007,7 +2153,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置子订单在redis中的主键
|
|
|
|
String minRecordKey = "minRecord:" + applicationOutRecordMin.getId(); |
|
|
|
// 将子订单主键插入到主订单的子订单列表
|
|
|
|
@ -2072,8 +2217,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
// 如果是通过仓库
|
|
|
|
|
|
|
|
|
|
|
|
@ -2127,7 +2271,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 将主订单插入到redis中
|
|
|
|
@ -2158,8 +2301,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 将当前redis中存储的spno删除
|
|
|
|
redisTemplate.delete(spNo); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 如果是部门负责人
|
|
|
|
|
|
|
|
String departmentheadTime = recordP.getDepartmentheadTime(); |
|
|
|
@ -2535,7 +2677,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
UserByPort applicantUser = LinkInterfaceUtil.FindUserById(record.getApplicantId(), userToken); |
|
|
|
|
|
|
|
|
|
|
|
if (map.containsKey("departmentheadPass") && !flagForHasOtherDepository && Integer.compare(applicantUser.getMaindeparment(),361) != 0) { |
|
|
|
if (map.containsKey("departmentheadPass") && !flagForHasOtherDepository && Integer.compare(applicantUser.getMaindeparment(), 361) != 0) { |
|
|
|
String result = ""; |
|
|
|
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|
|
|
map.put("departmentheadTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|
|
|
@ -2615,8 +2757,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
String result = ""; |
|
|
|
// 开启线程更改其他用户卡片模板样式
|
|
|
|
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|
|
|
@ -2672,7 +2813,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
minRecord.put("state", "1"); // 当前子订单状态 1待处理2处理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取出库仓库
|
|
|
|
Integer depositoryId = applicationOutRecordMin.getDepositoryId(); |
|
|
|
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
@ -2736,8 +2876,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendNotificationToDepositoryManager(QyWxUid.toString(), applicationOutRecordMin.getId(), userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
// 如果是通过仓库
|
|
|
|
|
|
|
|
|
|
|
|
@ -2825,8 +2964,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("departmentheadPass", 1); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
updateInventoryForOutRefused(record); |
|
|
|
result = "驳回"; |
|
|
|
map.put("pass", 2); |
|
|
|
|