|
|
|
@ -162,10 +162,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
page = ObjectFormatUtil.toInteger(map.get("page")); |
|
|
|
map.put("begin", (page - 1) * size); |
|
|
|
} |
|
|
|
|
|
|
|
List<StockTaking> myTask = stockTakingMapper.findMyTask(map); |
|
|
|
List<SimpleStockTakingP> stockTakingPS = new ArrayList<>(); |
|
|
|
for (int i = 0; i < myTask.size(); i++) { |
|
|
|
StockTaking stockTaking = myTask.get(i); |
|
|
|
for (StockTaking stockTaking : myTask) { |
|
|
|
SimpleStockTakingP ssp = new SimpleStockTakingP(stockTaking); |
|
|
|
Depository depositoryRecordById = depositoryMapper.findDepositoryById(stockTaking.getDepositoryId()); |
|
|
|
ssp.setDepositoryName(depositoryRecordById.getDname()); |
|
|
|
@ -358,9 +358,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 定义出错信息
|
|
|
|
List<String> err = new ArrayList<>(); |
|
|
|
|
|
|
|
Integer placeId = mainRecord.getPlaceId(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
Integer depositoryId = mainRecord.getDepositoryId(); |
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
@ -369,6 +367,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 获取子单详情
|
|
|
|
// 获取盘点的物料详情
|
|
|
|
|
|
|
|
Integer placeId = minRecord.getPid(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
String takingResult = minRecord.getTakingResult(); |
|
|
|
if ("Inventory_normal".equals(takingResult)) { |
|
|
|
@ -388,6 +390,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 获取物料与库位的对应关系
|
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据盘点结果重新计算物料的单价
|
|
|
|
|
|
|
|
|
|
|
|
@ -403,7 +407,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
int newNumberForPlace = 0; |
|
|
|
// 用于计算新的库位与物料对应关系的数量
|
|
|
|
int newNumberForMatrialAndPlace = 0; |
|
|
|
if ("Inventory_up".equals(takingResult)) { |
|
|
|
if ("Inventory_up".equals(takingResult)) |
|
|
|
{ |
|
|
|
// 如果盘盈
|
|
|
|
|
|
|
|
// 更新当前库位数量
|
|
|
|
@ -427,7 +432,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 更新物料与库位对应关系的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|
|
|
|
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
// 如果盘亏
|
|
|
|
newNumberForPlace = placeById.getQuantity() - inventory; |
|
|
|
@ -450,7 +456,6 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
normalMinId.add(minRecord.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@ -500,7 +505,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
map.put("departmentManager", userToken.getNumber()); |
|
|
|
stockTakingMapper.updateStockTaking(map); |
|
|
|
|
|
|
|
// 更新其他卡片
|
|
|
|
/*// 更新其他卡片
|
|
|
|
String finalStockTakingResult = stockTakingResult; |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
@ -513,7 +518,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
String responseCode = (String) redisTemplate.opsForHash().get(key, "responseCode"); |
|
|
|
qyWxOperationService.updateTemplateCard(responseCode, userToken.getName(), finalStockTakingResult, userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
}).start();*/ |
|
|
|
|
|
|
|
// 开启流程通知其他人忽略审批流程
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@ -522,8 +527,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
String departmentManager1 = mainRecord.getDepartmentManager(); |
|
|
|
String[] split = departmentManager1.split(","); |
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
String s = split[i]; |
|
|
|
for (String s : split) { |
|
|
|
if ("".equals(s.trim())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
@ -586,16 +590,15 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 定义出错信息
|
|
|
|
List<String> err = new ArrayList<>(); |
|
|
|
|
|
|
|
Integer placeId = mainRecord.getPlaceId(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
Integer depositoryId = mainRecord.getDepositoryId(); |
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); |
|
|
|
// 遍历当前拆单的子单详情
|
|
|
|
for (StockTakingChildP minRecord : minRecordList) { |
|
|
|
// 获取子单详情
|
|
|
|
|
|
|
|
Integer placeId = minRecord.getPid(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
String takingResult = minRecord.getTakingResult(); |
|
|
|
@ -613,7 +616,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 获取盘点物料信息
|
|
|
|
Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid()); |
|
|
|
|
|
|
|
|
|
|
|
// 定义用于获取物料与库位的对应关系的参数
|
|
|
|
Map<String, Object> paramForMaterialAndPlace = new HashMap<>(); |
|
|
|
paramForMaterialAndPlace.put("mid", inventoryById.getId()); |
|
|
|
paramForMaterialAndPlace.put("pid", placeById.getId()); |
|
|
|
@ -637,8 +640,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
mapForProducedDate.put("producedDate", producedDate); |
|
|
|
// 获取当前生产日期下的物料与生产日期的对应关系
|
|
|
|
MaterialAndProducedDate materialAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(mapForProducedDate); |
|
|
|
Integer oldInventroy = materialAndProducedDate.getInventory(); |
|
|
|
if (newInventory > oldInventroy) { |
|
|
|
Integer oldInventory = materialAndProducedDate.getInventory(); |
|
|
|
if (newInventory > oldInventory) { |
|
|
|
// 如果当前盘点数量大于库存数量
|
|
|
|
|
|
|
|
// 修改当前库存
|
|
|
|
@ -647,7 +650,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
materialAndProducedDate.setExpendnum(materialAndProducedDate.getQuantity() - newInventory); |
|
|
|
|
|
|
|
// 修改物料对应数量
|
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() + newInventory - oldInventroy); |
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() + newInventory - oldInventory); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
@ -659,14 +662,12 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
materialAndProducedDate.setExpendnum(materialAndProducedDate.getQuantity() - newInventory); |
|
|
|
|
|
|
|
// 修改物料对应数量
|
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() - oldInventroy + newInventory); |
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() - oldInventory + newInventory); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取当前物料数目
|
|
|
|
Integer quantity = inventoryById.getQuantity(); |
|
|
|
|
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
// 如果没有生产日期
|
|
|
|
|
|
|
|
// 获取当前库位以外的物料数量
|
|
|
|
@ -680,21 +681,20 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
} |
|
|
|
|
|
|
|
// 用于计算新的库位数量
|
|
|
|
Integer newNumberForPlace = 0; |
|
|
|
int newNumberForPlace = 0; |
|
|
|
// 用于计算新的库位与物料对应关系的数量
|
|
|
|
Integer newNumberForMatrialAndPlace = 0; |
|
|
|
int newNumberForMatrialAndPlace = 0; |
|
|
|
|
|
|
|
if ("Inventory_up".equals(takingResult)) { |
|
|
|
// 如果盘盈
|
|
|
|
|
|
|
|
// 如果是基础单位
|
|
|
|
if ("-1".equals(unit)) { |
|
|
|
if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) { |
|
|
|
|
|
|
|
// 更新当前库位数量
|
|
|
|
newNumberForPlace = placeById.getQuantity() + inventory; |
|
|
|
|
|
|
|
if (newNumberForPlace <= placeById.getMax()) { |
|
|
|
|
|
|
|
// 如果更新后的库位数量没有上溢
|
|
|
|
|
|
|
|
// 更新当前库位的数量
|
|
|
|
@ -714,16 +714,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
} |
|
|
|
else { |
|
|
|
// 如果是拆单单位
|
|
|
|
// 更新当前库位数量
|
|
|
|
newNumberForPlace = placeById.getQuantity() + inventory; |
|
|
|
|
|
|
|
if (newNumberForPlace > placeById.getMax()) { |
|
|
|
// 添加错误信息
|
|
|
|
errIds.add(minRecord.getId()); |
|
|
|
err.add("当前库位数量溢出,需要转移"); |
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
// 用于查找对应的拆单记录
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
@ -733,8 +725,9 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
// 查找当前拆单记录对应的库存记录
|
|
|
|
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); |
|
|
|
|
|
|
|
// 如果存在拆单库存记录
|
|
|
|
if(splitInventory != null){ |
|
|
|
// 获取当前盘点后的库存数
|
|
|
|
int realQuantity = Math.round(inventory) + splitInventory.getSaveQuantity(); |
|
|
|
// 定义当前进制
|
|
|
|
int scale = splitInfo.getQuantity(); |
|
|
|
@ -775,8 +768,21 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 修改拆单库存
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
} |
|
|
|
else{ |
|
|
|
// 如果不存在拆单库存记录
|
|
|
|
|
|
|
|
Map<String, Object> paramForUpdateSplitInventory = new HashMap<>(); |
|
|
|
paramForUpdateSplitInventory.put("placeId",minRecord.getPid()); |
|
|
|
paramForUpdateSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); |
|
|
|
paramForUpdateSplitInventory.put("quantity",inventory); |
|
|
|
paramForUpdateSplitInventory.put("mid",inventoryById.getMid()); |
|
|
|
paramForUpdateSplitInventory.put("unit",minRecord.getUnit()); |
|
|
|
|
|
|
|
splitUnitService.realInInventoryToDepository(Double.valueOf(inventory), null,paramForUpdateSplitInventory,splitInfo,placeAndMaterialByMidAndPid,false); |
|
|
|
if (paramForUpdateSplitInventory.containsKey("applicationInId")) { |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateSplitInventory.get("applicationInId"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -785,7 +791,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
else { |
|
|
|
|
|
|
|
// 如果盘亏
|
|
|
|
if ("-1".equals(unit)) { |
|
|
|
if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) { |
|
|
|
// 如果盘点的是基础单位
|
|
|
|
|
|
|
|
newNumberForPlace = placeById.getQuantity() - inventory; |
|
|
|
@ -875,13 +881,12 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
map.put("minIds", minIds); |
|
|
|
// 开启一个线程用于发送抄送信息给负责人
|
|
|
|
StockTaking finalMainRecord = mainRecord; |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
String s = QyWxUid.toString(); |
|
|
|
s = "PangFuZhen,"; |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(s, map, userToken, finalMainRecord, userAgent); |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(s, map, userToken, mainRecord, userAgent); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
|
|
|
|
@ -945,10 +950,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
List<Long> errIds = new ArrayList<>(); |
|
|
|
// 定义出错信息
|
|
|
|
List<String> err = new ArrayList<>(); |
|
|
|
// 获取盘点的库位id
|
|
|
|
Integer placeId = mainRecord.getPlaceId(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
// 获取盘点的仓库id
|
|
|
|
Integer depositoryId = mainRecord.getDepositoryId(); |
|
|
|
// 获取仓库详情
|
|
|
|
@ -961,6 +963,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 获取当前盘点的计量单位
|
|
|
|
String unit = minRecord.getUnit(); |
|
|
|
|
|
|
|
// 获取盘点的库位id
|
|
|
|
Integer placeId = minRecord.getPid(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
String takingResult = minRecord.getTakingResult(); |
|
|
|
@ -1444,15 +1450,17 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 定义出错信息
|
|
|
|
List<String> err = new ArrayList<>(); |
|
|
|
|
|
|
|
Integer placeId = mainRecord.getPlaceId(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
Integer depositoryId = mainRecord.getDepositoryId(); |
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(ObjectFormatUtil.toInteger(mainId)); |
|
|
|
for (StockTakingChildP minRecord : minRecordList) { |
|
|
|
// 获取子单详情
|
|
|
|
Integer placeId = minRecord.getPid(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
|
|
|
|
// 获取盘点的物料详情
|
|
|
|
|
|
|
|
@ -1646,7 +1654,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 如果转移前的库位为空
|
|
|
|
if (oldPlace == null) { |
|
|
|
// 查询当前主订单对应的盘点库位
|
|
|
|
oldPlace = placeMapper.findPlaceById(mainRecord.getPlaceId()); |
|
|
|
oldPlace = placeMapper.findPlaceById(minRecord.getPid()); |
|
|
|
// 设置当前转移前库位的总数
|
|
|
|
sumTransferAfter = oldPlace.getQuantity(); |
|
|
|
} |
|
|
|
@ -2519,12 +2527,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 定义出错信息
|
|
|
|
List<String> err = new ArrayList<>(); |
|
|
|
|
|
|
|
Integer placeId = mainRecord.getPlaceId(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
Integer depositoryId = mainRecord.getDepositoryId(); |
|
|
|
// 获取仓库详情
|
|
|
|
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
@ -2532,7 +2535,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
for (int i = 0; i < minRecordList.size(); i++) { |
|
|
|
// 获取子单详情
|
|
|
|
StockTakingChildP minRecord = minRecordList.get(i); |
|
|
|
// 获取盘点的物料详情
|
|
|
|
|
|
|
|
Integer placeId = minRecord.getPid(); |
|
|
|
// 获取库位详情
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
String takingResult = minRecord.getTakingResult(); |
|
|
|
|