完善库存统计接口,增加移动平均价的逻辑

This commit is contained in:
jishenghua
2024-05-24 01:22:32 +08:00
parent 0292446e15
commit 28548c7957
9 changed files with 124 additions and 9 deletions

View File

@@ -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