给商品库存和进销存统计增加库存分布的查看功能
This commit is contained in:
@@ -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.datasource.vo.InOutPriceVo;
|
||||
import com.jsh.erp.datasource.vo.MaterialDepotStock;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.DepotService;
|
||||
import com.jsh.erp.service.DepotHeadService;
|
||||
@@ -355,6 +356,7 @@ public class DepotItemController {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Long mId = diEx.getMId();
|
||||
item.put("id", mId);
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("materialName", diEx.getMName());
|
||||
item.put("materialModel", diEx.getMModel());
|
||||
@@ -472,6 +474,67 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据仓库和商品查询库存分布情况-带时间段参数
|
||||
* @param mId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialDepotStockByParam")
|
||||
@ApiOperation(value = "根据仓库和商品查询库存分布情况-带时间段参数")
|
||||
public String getMaterialDepotStockByParam(
|
||||
@RequestParam(value = "depotIds",required = false) String depotIds,
|
||||
@RequestParam("materialId") Long mId,
|
||||
@RequestParam(value = "unitPrice", required = false) BigDecimal unitPrice,
|
||||
@RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
Map<Long, String> depotMap = new HashMap<>();
|
||||
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
||||
for (Object depotObj: depotArr) {
|
||||
if(depotObj!=null) {
|
||||
JSONObject depotObject = JSONObject.parseObject(depotObj.toString());
|
||||
depotMap.put(depotObject.getLong("id"), depotObject.getString("depotName"));
|
||||
}
|
||||
}
|
||||
String[] depotIdArr = null;
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotIdArr = depotIds.split(",");
|
||||
}
|
||||
List<Long> depotList = depotService.parseDepotListByArr(depotIdArr);
|
||||
Long[] depotIdArray = StringUtil.listToLongArray(depotList);
|
||||
List<MaterialDepotStock> list = new ArrayList<>();
|
||||
for (int i = 0; i < depotIdArray.length; i++) {
|
||||
Long depotId = depotIdArray[i];
|
||||
List<Long> currentDepotIdList = new ArrayList<>();
|
||||
currentDepotIdList.add(depotId);
|
||||
String depotName = depotMap.get(depotId);
|
||||
MaterialDepotStock materialDepotStock = new MaterialDepotStock();
|
||||
materialDepotStock.setDepotId(depotId);
|
||||
materialDepotStock.setDepotName(depotName);
|
||||
BigDecimal prevSum = depotItemService.getStockByParamWithDepotList(currentDepotIdList,mId,null,beginTime);
|
||||
Map<String,BigDecimal> intervalMap = depotItemService.getIntervalMapByParamWithDepotList(currentDepotIdList,mId,beginTime,endTime);
|
||||
BigDecimal inSum = intervalMap.get("inSum");
|
||||
BigDecimal outSum = intervalMap.get("outSum");
|
||||
BigDecimal thisSum = prevSum.add(inSum).subtract(outSum);
|
||||
materialDepotStock.setCurrentNumber(thisSum);
|
||||
materialDepotStock.setUnitPrice(unitPrice);
|
||||
if(materialDepotStock.getCurrentNumber()!=null && materialDepotStock.getUnitPrice()!=null ) {
|
||||
materialDepotStock.setAllPrice(materialDepotStock.getCurrentNumber().multiply(materialDepotStock.getUnitPrice()));
|
||||
}
|
||||
if(thisSum.compareTo(BigDecimal.ZERO)!=0) {
|
||||
list.add(materialDepotStock);
|
||||
}
|
||||
}
|
||||
objectMap.put("rows", list);
|
||||
objectMap.put("total", list.size());
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
private List<Long> parseListByDepotIds(@RequestParam("depotIds") String depotIds) throws Exception {
|
||||
List<Long> depotList = new ArrayList<>();
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.Material;
|
||||
import com.jsh.erp.datasource.entities.MaterialExtend;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import com.jsh.erp.datasource.entities.Unit;
|
||||
import com.jsh.erp.datasource.vo.MaterialDepotStock;
|
||||
import com.jsh.erp.service.DepotService;
|
||||
import com.jsh.erp.service.DepotItemService;
|
||||
import com.jsh.erp.service.MaterialService;
|
||||
@@ -842,4 +843,20 @@ public class MaterialController extends BaseController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据仓库和商品查询库存分布情况
|
||||
* @param mId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialDepotStock")
|
||||
@ApiOperation(value = "根据仓库和商品查询库存分布情况")
|
||||
public TableDataInfo getMaterialDepotStock(
|
||||
@RequestParam(value = "depotIds",required = false) String depotIds,
|
||||
@RequestParam("materialId") Long mId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
List<MaterialDepotStock> list = materialService.getMaterialDepotStock(depotIds, mId);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsh.erp.datasource.mappers;
|
||||
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.vo.MaterialDepotStock;
|
||||
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -165,4 +166,8 @@ public interface MaterialMapperEx {
|
||||
|
||||
MaterialExtend getMaterialExtendBySerialNumber(
|
||||
@Param("serialNumber") String serialNumber);
|
||||
|
||||
List<MaterialDepotStock> getMaterialDepotStock(
|
||||
@Param("depotIdArray") Long[] depotIdArray,
|
||||
@Param("mId") Long mId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jsh.erp.datasource.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class MaterialDepotStock {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long materialId;
|
||||
|
||||
private Long depotId;
|
||||
|
||||
private String depotName;
|
||||
|
||||
private BigDecimal currentNumber;
|
||||
|
||||
private BigDecimal currentUnitPrice;
|
||||
|
||||
private BigDecimal purchaseDecimal;
|
||||
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
private BigDecimal allPrice;
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.*;
|
||||
import com.jsh.erp.datasource.vo.MaterialDepotStock;
|
||||
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
@@ -1495,4 +1496,27 @@ public class MaterialService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<MaterialDepotStock> getMaterialDepotStock(String depotIds, Long mId) throws Exception {
|
||||
String[] depotIdArr = null;
|
||||
if(StringUtil.isNotEmpty(depotIds)) {
|
||||
depotIdArr = depotIds.split(",");
|
||||
}
|
||||
boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<Long> depotList = depotService.parseDepotListByArr(depotIdArr);
|
||||
Long[] depotIdArray = StringUtil.listToLongArray(depotList);
|
||||
PageUtils.startPage();
|
||||
List<MaterialDepotStock> list = materialMapperEx.getMaterialDepotStock(depotIdArray, mId);
|
||||
for (MaterialDepotStock item: list) {
|
||||
if(moveAvgPriceFlag) {
|
||||
item.setUnitPrice(item.getCurrentUnitPrice());
|
||||
} else {
|
||||
item.setUnitPrice(item.getPurchaseDecimal());
|
||||
}
|
||||
if(item.getCurrentNumber()!=null && item.getUnitPrice()!=null ) {
|
||||
item.setAllPrice(item.getCurrentNumber().multiply(item.getUnitPrice()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -830,4 +830,19 @@
|
||||
limit 0,1
|
||||
</select>
|
||||
|
||||
<select id="getMaterialDepotStock" resultType="com.jsh.erp.datasource.vo.MaterialDepotStock">
|
||||
select mcs.id, mcs.material_id, mcs.depot_id, d.name depotName, mcs.current_number,
|
||||
ifnull(me.purchase_decimal,0) purchase_decimal, ifnull(mcs.current_unit_price,0) currentUnitPrice
|
||||
from jsh_material_current_stock mcs
|
||||
left join jsh_material_extend me on me.material_id=mcs.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||
left join jsh_depot d on mcs.depot_id=d.id and ifnull(d.delete_flag,'0') !='1'
|
||||
where me.default_flag=1 and ifnull(mcs.current_number,0)!=0
|
||||
and mcs.material_id=#{mId}
|
||||
<if test="depotIdArray != null and depotIdArray.length>0">
|
||||
and mcs.depot_id in (
|
||||
<foreach collection="depotIdArray" item="depotId" separator=",">#{depotId}</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user