完善库存统计接口,增加移动平均价的逻辑
This commit is contained in:
@@ -554,9 +554,11 @@ public class DepotHeadService {
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新当前库存
|
||||
for (DepotItem depotItem : list) {
|
||||
//更新当前库存
|
||||
depotItemService.updateCurrentStock(depotItem);
|
||||
//更新当前成本价
|
||||
depotItemService.updateCurrentUnitPrice(depotItem);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||
|
||||
@@ -1277,8 +1277,9 @@ public class MaterialService {
|
||||
return materialMapperEx.getInitialStockWithMaterial(depotList);
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> getListWithStock(List<Long> depotList, List<Long> idList, String position, String materialParam, Integer zeroStock,
|
||||
String column, String order, Integer offset, Integer rows) throws Exception {
|
||||
public List<MaterialVo4Unit> getListWithStock(List<Long> depotList, List<Long> idList, String position, String materialParam,
|
||||
Boolean moveAvgPriceFlag, Integer zeroStock, String column, String order,
|
||||
Integer offset, Integer rows) throws Exception {
|
||||
Map<Long, BigDecimal> initialStockMap = new HashMap<>();
|
||||
List<MaterialInitialStockWithMaterial> initialStockList = getInitialStockWithMaterial(depotList);
|
||||
for (MaterialInitialStockWithMaterial mism: initialStockList) {
|
||||
@@ -1286,6 +1287,9 @@ public class MaterialService {
|
||||
}
|
||||
List<MaterialVo4Unit> dataList = materialMapperEx.getListWithStock(depotList, idList, position, materialParam, zeroStock, column, order, offset, rows);
|
||||
for(MaterialVo4Unit item: dataList) {
|
||||
if(moveAvgPriceFlag) {
|
||||
item.setPurchaseDecimal(item.getCurrentUnitPrice());
|
||||
}
|
||||
item.setUnitName(null!=item.getUnitId()?item.getUnitName() + "[多单位]":item.getUnitName());
|
||||
item.setInitialStock(null!=initialStockMap.get(item.getId())?initialStockMap.get(item.getId()):BigDecimal.ZERO);
|
||||
item.setBigUnitStock(getBigUnitStock(item.getCurrentStock(), item.getUnitId()));
|
||||
@@ -1362,6 +1366,19 @@ public class MaterialService {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchSetMaterialCurrentUnitPrice(String ids) throws Exception {
|
||||
int res = 0;
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
for(Long mId: idList) {
|
||||
DepotItem depotItem = new DepotItem();
|
||||
depotItem.setMaterialId(mId);
|
||||
depotItemService.updateCurrentUnitPrice(depotItem);
|
||||
res = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public int batchUpdate(JSONObject jsonObject) {
|
||||
String ids = jsonObject.getString("ids");
|
||||
String materialStr = jsonObject.getString("material");
|
||||
|
||||
@@ -507,6 +507,23 @@ public class SystemConfigService {
|
||||
return inOutManageFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取移动平均价开关
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean getMoveAvgPriceFlag() throws Exception {
|
||||
boolean moveAvgPriceFlag = false;
|
||||
List<SystemConfig> list = getSystemConfig();
|
||||
if(list.size()>0) {
|
||||
String flag = list.get(0).getMoveAvgPriceFlag();
|
||||
if(("1").equals(flag)) {
|
||||
moveAvgPriceFlag = true;
|
||||
}
|
||||
}
|
||||
return moveAvgPriceFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel导出统一方法
|
||||
* @param title
|
||||
|
||||
Reference in New Issue
Block a user