优化进销存统计接口
This commit is contained in:
parent
3b3805ee93
commit
f89d8f2a3f
@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
||||
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.materialExtend.MaterialExtendService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
@ -53,6 +54,9 @@ public class DepotItemController {
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@ -277,7 +281,7 @@ public class DepotItemController {
|
||||
* 查找所有的明细
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param depotId
|
||||
* @param depotIds
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
@ -289,16 +293,27 @@ public class DepotItemController {
|
||||
@ApiOperation(value = "查找所有的明细")
|
||||
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam(value = "depotId", required = false) Long depotId,
|
||||
@RequestParam(value = "depotIds", required = false) String depotIds,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String timeA = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String timeB = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
try {
|
||||
String timeA = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String timeB = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
List<Long> depotList = new ArrayList<>();
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotList = StringUtil.strToLongList(depotIds);
|
||||
} else {
|
||||
//未选择仓库时默认为当前用户有权限的仓库
|
||||
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
||||
for(Object obj: depotArr) {
|
||||
JSONObject object = JSONObject.parseObject(obj.toString());
|
||||
depotList.add(object.getLong("id"));
|
||||
}
|
||||
}
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
timeB,(currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
@ -324,11 +339,23 @@ public class DepotItemController {
|
||||
item.put("materialOther", materialOther);
|
||||
item.put("materialColor", diEx.getMColor());
|
||||
item.put("unitName", diEx.getMaterialUnit());
|
||||
|
||||
item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA));
|
||||
item.put("inSum", depotItemService.getInNumByParam(depotId,mId,timeA,timeB));
|
||||
item.put("outSum", depotItemService.getOutNumByParam(depotId,mId,timeA,timeB));
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB);
|
||||
BigDecimal prevSum = BigDecimal.ZERO;
|
||||
BigDecimal inSum = BigDecimal.ZERO;
|
||||
BigDecimal outSum = BigDecimal.ZERO;
|
||||
BigDecimal thisSum = BigDecimal.ZERO;
|
||||
for(Long depotId: depotList) {
|
||||
BigDecimal prevSumStock = depotItemService.getStockByParam(depotId,mId,null,timeA);
|
||||
BigDecimal inSumStock = depotItemService.getInNumByParam(depotId,mId,timeA,timeB);
|
||||
BigDecimal outSumStock = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB);
|
||||
BigDecimal thisSumStock = depotItemService.getStockByParam(depotId,mId,null,timeB);
|
||||
prevSum = prevSum.add(prevSumStock);
|
||||
inSum = inSum.add(inSumStock);
|
||||
outSum = outSum.add(outSumStock);
|
||||
thisSum = thisSum.add(thisSumStock);
|
||||
}
|
||||
item.put("prevSum", prevSum);
|
||||
item.put("inSum", inSum);
|
||||
item.put("outSum", outSum);
|
||||
item.put("thisSum", thisSum);
|
||||
for(MaterialExtend me:meList) {
|
||||
if(me.getMaterialId().longValue() == diEx.getMId().longValue()) {
|
||||
@ -354,7 +381,7 @@ public class DepotItemController {
|
||||
|
||||
/**
|
||||
* 统计总计金额
|
||||
* @param depotId
|
||||
* @param depotIds
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param request
|
||||
@ -362,21 +389,36 @@ public class DepotItemController {
|
||||
*/
|
||||
@GetMapping(value = "/totalCountMoney")
|
||||
@ApiOperation(value = "统计总计金额")
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam(value = "depotId", required = false) Long depotId,
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam(value = "depotIds", required = false) String depotIds,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
try {
|
||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
List<Long> depotList = new ArrayList<>();
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotList = StringUtil.strToLongList(depotIds);
|
||||
} else {
|
||||
//未选择仓库时默认为当前用户有权限的仓库
|
||||
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
||||
for(Object obj: depotArr) {
|
||||
JSONObject object = JSONObject.parseObject(obj.toString());
|
||||
depotList.add(object.getLong("id"));
|
||||
}
|
||||
}
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
endTime, null, null);
|
||||
BigDecimal thisAllPrice = BigDecimal.ZERO;
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,endTime);
|
||||
BigDecimal thisSum = BigDecimal.ZERO;
|
||||
for(Long depotId: depotList) {
|
||||
BigDecimal thisSumStock = depotItemService.getStockByParam(depotId,mId,null,endTime);
|
||||
thisSum = thisSum.add(thisSumStock);
|
||||
}
|
||||
BigDecimal unitPrice = diEx.getPurchaseDecimal();
|
||||
if(unitPrice == null) {
|
||||
unitPrice = BigDecimal.ZERO;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user