完善库存统计接口,增加移动平均价的逻辑
This commit is contained in:
@@ -332,6 +332,7 @@ public class DepotItemController {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<Long> categoryIdList = new ArrayList<>();
|
||||
if(categoryId != null){
|
||||
categoryIdList = materialService.getListByParentId(categoryId);
|
||||
@@ -371,7 +372,11 @@ public class DepotItemController {
|
||||
item.put("thisSum", thisSum);
|
||||
//将小单位的库存换算为大单位的库存
|
||||
item.put("bigUnitStock", materialService.getBigUnitStock(thisSum, diEx.getUnitId()));
|
||||
item.put("unitPrice", diEx.getPurchaseDecimal());
|
||||
if(moveAvgPriceFlag) {
|
||||
item.put("unitPrice", diEx.getCurrentUnitPrice());
|
||||
} else {
|
||||
item.put("unitPrice", diEx.getPurchaseDecimal());
|
||||
}
|
||||
item.put("thisAllPrice", thisSum.multiply(diEx.getPurchaseDecimal()));
|
||||
dataArray.add(item);
|
||||
}
|
||||
@@ -408,6 +413,7 @@ public class DepotItemController {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<Long> categoryIdList = new ArrayList<>();
|
||||
if(categoryId != null){
|
||||
categoryIdList = materialService.getListByParentId(categoryId);
|
||||
@@ -423,7 +429,12 @@ public class DepotItemController {
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParamWithDepotList(depotList,mId,null,endTime);
|
||||
thisAllStock = thisAllStock.add(thisSum);
|
||||
BigDecimal unitPrice = diEx.getPurchaseDecimal();
|
||||
BigDecimal unitPrice = null;
|
||||
if(moveAvgPriceFlag) {
|
||||
unitPrice = diEx.getCurrentUnitPrice();
|
||||
} else {
|
||||
unitPrice = diEx.getPurchaseDecimal();
|
||||
}
|
||||
if(unitPrice == null) {
|
||||
unitPrice = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
import com.jsh.erp.service.role.RoleService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.unit.UnitService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
@@ -48,6 +49,9 @@ public class MaterialController {
|
||||
@Resource
|
||||
private DepotItemService depotItemService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@@ -579,7 +583,7 @@ public class MaterialController {
|
||||
* @param depotIds
|
||||
* @param categoryId
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
* @param zeroStock
|
||||
* @param column
|
||||
* @param order
|
||||
* @param request
|
||||
@@ -616,13 +620,18 @@ public class MaterialController {
|
||||
depotList.add(object.getLong("id"));
|
||||
}
|
||||
}
|
||||
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<MaterialVo4Unit> dataList = materialService.getListWithStock(depotList, idList, StringUtil.toNull(position), StringUtil.toNull(materialParam),
|
||||
zeroStock, StringUtil.safeSqlParse(column), StringUtil.safeSqlParse(order), (currentPage-1)*pageSize, pageSize);
|
||||
moveAvgPriceFlag, zeroStock, StringUtil.safeSqlParse(column), StringUtil.safeSqlParse(order), (currentPage-1)*pageSize, pageSize);
|
||||
int total = materialService.getListWithStockCount(depotList, idList, StringUtil.toNull(position), StringUtil.toNull(materialParam), zeroStock);
|
||||
MaterialVo4Unit materialVo4Unit= materialService.getTotalStockAndPrice(depotList, idList, StringUtil.toNull(position), StringUtil.toNull(materialParam));
|
||||
map.put("total", total);
|
||||
map.put("currentStock", materialVo4Unit.getCurrentStock()!=null?materialVo4Unit.getCurrentStock():BigDecimal.ZERO);
|
||||
map.put("currentStockPrice", materialVo4Unit.getCurrentStockPrice()!=null?materialVo4Unit.getCurrentStockPrice():BigDecimal.ZERO);
|
||||
if(moveAvgPriceFlag) {
|
||||
map.put("currentStockPrice", materialVo4Unit.getCurrentStockMovePrice()!=null?materialVo4Unit.getCurrentStockMovePrice():BigDecimal.ZERO);
|
||||
} else {
|
||||
map.put("currentStockPrice", materialVo4Unit.getCurrentStockPrice()!=null?materialVo4Unit.getCurrentStockPrice():BigDecimal.ZERO);
|
||||
}
|
||||
map.put("currentWeight", materialVo4Unit.getCurrentWeight()!=null?materialVo4Unit.getCurrentWeight():BigDecimal.ZERO);
|
||||
map.put("rows", dataList);
|
||||
res.code = 200;
|
||||
@@ -656,6 +665,27 @@ public class MaterialController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置商品当前的成本价
|
||||
* @param jsonObject
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping(value = "/batchSetMaterialCurrentUnitPrice")
|
||||
@ApiOperation(value = "批量设置商品当前的成本价")
|
||||
public String batchSetMaterialCurrentUnitPrice(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request)throws Exception {
|
||||
String ids = jsonObject.getString("ids");
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
int res = materialService.batchSetMaterialCurrentUnitPrice(ids);
|
||||
if(res > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新商品信息
|
||||
* @param jsonObject
|
||||
|
||||
Reference in New Issue
Block a user