|
|
|
@ -938,6 +938,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Integer completeStockTakingByQyWx(TemplateCard templateCard, String userAgent) { |
|
|
|
|
|
|
|
// 定义结果集
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
// 获取点击的按钮
|
|
|
|
@ -969,23 +971,22 @@ 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(); |
|
|
|
// 获取仓库详情
|
|
|
|
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); |
|
|
|
for (int i = 0; i < minRecordList.size(); i++) { |
|
|
|
// 获取子单详情
|
|
|
|
StockTakingChildP minRecord = minRecordList.get(i); |
|
|
|
for (StockTakingChildP minRecord : minRecordList) { |
|
|
|
|
|
|
|
// 获取当前盘点的计量单位
|
|
|
|
String unit = minRecord.getUnit(); |
|
|
|
|
|
|
|
// 获取盘点的物料详情
|
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
String takingResult = minRecord.getTakingResult(); |
|
|
|
@ -997,9 +998,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 获取盈亏数量
|
|
|
|
Integer inventory = minRecord.getInventory(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取盘点物料信息
|
|
|
|
Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid()); |
|
|
|
|
|
|
|
// 用于获取物料与库位的对应关系
|
|
|
|
Map<String, Object> paramForMaterialAndPlace = new HashMap<>(); |
|
|
|
paramForMaterialAndPlace.put("mid", inventoryById.getId()); |
|
|
|
paramForMaterialAndPlace.put("pid", placeById.getId()); |
|
|
|
@ -1008,13 +1010,12 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
// 根据盘点结果重新计算物料的单价
|
|
|
|
|
|
|
|
// 数据库中的总额
|
|
|
|
// 获取判断对应的生产日期
|
|
|
|
Long producedDate = minRecord.getProducedDate(); |
|
|
|
|
|
|
|
|
|
|
|
// 数据库中的总额
|
|
|
|
Double amounts = (inventoryById.getAmounts() / 100); |
|
|
|
double amounts = (inventoryById.getAmounts() / 100); |
|
|
|
// 当前盘点数目
|
|
|
|
Integer newInventory = minRecord.getNewInventory(); |
|
|
|
|
|
|
|
@ -1069,7 +1070,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
inventoryById.setPrice(avgPrice); |
|
|
|
|
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
// 如果没有生产日期
|
|
|
|
|
|
|
|
// 获取当前生产日期中的物料
|
|
|
|
@ -1116,6 +1118,8 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
// 新的均价
|
|
|
|
avgPrice = (amounts / (quantity)) * 100; |
|
|
|
BigDecimal bg = new BigDecimal(avgPrice); |
|
|
|
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
} |
|
|
|
// 更新物料单价
|
|
|
|
inventoryById.setPrice(avgPrice); |
|
|
|
@ -1248,6 +1252,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
} else { |
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
// 用于查找对应的拆单记录
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
@ -1348,6 +1353,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Map<String, Object> reviewByQyWxApproval(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo) { |
|
|
|
// 定义结果集
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
// 用于进行修改数据
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
@ -1414,9 +1420,9 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
// 获取所有子单
|
|
|
|
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(ObjectFormatUtil.toInteger(mainId)); |
|
|
|
for (int i = 0; i < minRecordList.size(); i++) { |
|
|
|
for (StockTakingChildP minRecord : minRecordList) { |
|
|
|
// 获取子单详情
|
|
|
|
StockTakingChildP minRecord = minRecordList.get(i); |
|
|
|
|
|
|
|
// 获取盘点的物料详情
|
|
|
|
|
|
|
|
// 获取当前盘点结果
|
|
|
|
@ -1430,10 +1436,10 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
Integer inventory = minRecord.getInventory(); |
|
|
|
|
|
|
|
|
|
|
|
Material materialById = materialMapper.findMaterialById(minRecord.getMid()); |
|
|
|
Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid()); |
|
|
|
|
|
|
|
Map<String, Object> paramForMaterialAndPlace = new HashMap<>(); |
|
|
|
paramForMaterialAndPlace.put("mid", materialById.getId()); |
|
|
|
paramForMaterialAndPlace.put("mid", inventoryById.getId()); |
|
|
|
paramForMaterialAndPlace.put("pid", placeById.getId()); |
|
|
|
// 获取物料与库位的对应关系
|
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|
|
|
@ -1441,7 +1447,7 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
// 根据盘点结果重新计算物料的单价
|
|
|
|
|
|
|
|
// 数据库中的总额
|
|
|
|
Double amounts = (materialById.getAmounts() / 100); |
|
|
|
Double amounts = (inventoryById.getAmounts() / 100); |
|
|
|
|
|
|
|
Integer newInventory = minRecord.getNewInventory(); |
|
|
|
Double avgPrice = 0.0; |
|
|
|
@ -1450,13 +1456,15 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
|
|
|
|
|
// 新的均价
|
|
|
|
avgPrice = (amounts / newInventory) * 100; |
|
|
|
BigDecimal bg = new BigDecimal(avgPrice); |
|
|
|
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
} |
|
|
|
materialById.setPrice(avgPrice); |
|
|
|
inventoryById.setPrice(avgPrice); |
|
|
|
|
|
|
|
// 获取当前库位上物料数量
|
|
|
|
Integer oldQuantity = materialById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); |
|
|
|
Integer oldQuantity = inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); |
|
|
|
|
|
|
|
materialById.setQuantity(oldQuantity + newInventory); |
|
|
|
inventoryById.setQuantity(oldQuantity + newInventory); |
|
|
|
|
|
|
|
|
|
|
|
// 用于计算新的库位数量
|
|
|
|
|