给商品库存和进销存统计增加库存分布的查看功能

This commit is contained in:
jishenghua
2025-08-29 15:13:06 +08:00
parent ff097ebf21
commit 1dbda0462c
10 changed files with 445 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount; import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList; import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
import com.jsh.erp.datasource.vo.InOutPriceVo; import com.jsh.erp.datasource.vo.InOutPriceVo;
import com.jsh.erp.datasource.vo.MaterialDepotStock;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.DepotService; import com.jsh.erp.service.DepotService;
import com.jsh.erp.service.DepotHeadService; import com.jsh.erp.service.DepotHeadService;
@@ -355,6 +356,7 @@ public class DepotItemController {
for (DepotItemVo4WithInfoEx diEx : dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
Long mId = diEx.getMId(); Long mId = diEx.getMId();
item.put("id", mId);
item.put("barCode", diEx.getBarCode()); item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName()); item.put("materialName", diEx.getMName());
item.put("materialModel", diEx.getMModel()); item.put("materialModel", diEx.getMModel());
@@ -472,6 +474,67 @@ public class DepotItemController {
return res; 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 { private List<Long> parseListByDepotIds(@RequestParam("depotIds") String depotIds) throws Exception {
List<Long> depotList = new ArrayList<>(); List<Long> depotList = new ArrayList<>();
if(StringUtil.isNotEmpty(depotIds)) { if(StringUtil.isNotEmpty(depotIds)) {

View File

@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.Material;
import com.jsh.erp.datasource.entities.MaterialExtend; import com.jsh.erp.datasource.entities.MaterialExtend;
import com.jsh.erp.datasource.entities.MaterialVo4Unit; import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.entities.Unit; 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.DepotService;
import com.jsh.erp.service.DepotItemService; import com.jsh.erp.service.DepotItemService;
import com.jsh.erp.service.MaterialService; import com.jsh.erp.service.MaterialService;
@@ -842,4 +843,20 @@ public class MaterialController extends BaseController {
} }
return res; 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);
}
} }

View File

@@ -1,6 +1,7 @@
package com.jsh.erp.datasource.mappers; package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.MaterialDepotStock;
import com.jsh.erp.datasource.vo.MaterialVoSearch; import com.jsh.erp.datasource.vo.MaterialVoSearch;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -165,4 +166,8 @@ public interface MaterialMapperEx {
MaterialExtend getMaterialExtendBySerialNumber( MaterialExtend getMaterialExtendBySerialNumber(
@Param("serialNumber") String serialNumber); @Param("serialNumber") String serialNumber);
List<MaterialDepotStock> getMaterialDepotStock(
@Param("depotIdArray") Long[] depotIdArray,
@Param("mId") Long mId);
} }

View File

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

View File

@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*; import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.vo.MaterialDepotStock;
import com.jsh.erp.datasource.vo.MaterialVoSearch; import com.jsh.erp.datasource.vo.MaterialVoSearch;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
@@ -1495,4 +1496,27 @@ public class MaterialService {
return null; 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;
}
}

View File

@@ -830,4 +830,19 @@
limit 0,1 limit 0,1
</select> </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> </mapper>

View File

@@ -81,6 +81,9 @@
:scroll="scroll" :scroll="scroll"
:loading="loading" :loading="loading"
@change="handleTableChange"> @change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="showMaterialDepotStockList(record)">{{record.id?'分布':''}}</a>
</span>
<span slot="customTitle"> <span slot="customTitle">
<a-popover trigger="click" placement="right"> <a-popover trigger="click" placement="right">
<template slot="content"> <template slot="content">
@@ -142,11 +145,13 @@
</a-row> </a-row>
</section> </section>
<!-- table区域-end --> <!-- table区域-end -->
<material-depot-stock-list-with-time ref="materialDepotStockListWithTime" @ok="modalFormOk"></material-depot-stock-list-with-time>
</a-card> </a-card>
</a-col> </a-col>
</a-row> </a-row>
</template> </template>
<script> <script>
import MaterialDepotStockListWithTime from './modules/MaterialDepotStockListWithTime'
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, getFileAccessHttpUrl } from '@/api/manage' import { getAction, getFileAccessHttpUrl } from '@/api/manage'
import {queryMaterialCategoryTreeList} from '@/api/api' import {queryMaterialCategoryTreeList} from '@/api/api'
@@ -158,6 +163,7 @@
name: "InOutStockReport", name: "InOutStockReport",
mixins:[JeecgListMixin], mixins:[JeecgListMixin],
components: { components: {
MaterialDepotStockListWithTime,
JEllipsis JEllipsis
}, },
data () { data () {
@@ -192,7 +198,7 @@
totalCountMoneyStr: '0', totalCountMoneyStr: '0',
pageName: 'inOutStockReport', pageName: 'inOutStockReport',
// 默认索引 // 默认索引
defDataIndex:['rowIndex','barCode','materialName','materialStandard','materialModel','unitName','unitPrice', defDataIndex:['rowIndex','action','barCode','materialName','materialStandard','materialModel','unitName','unitPrice',
'prevSum','inSum','outSum','thisSum','thisAllPrice'], 'prevSum','inSum','outSum','thisSum','thisAllPrice'],
// 默认列 // 默认列
defColumns: [ defColumns: [
@@ -202,6 +208,9 @@
return (t !== '合计') ? (parseInt(index) + 1) : t return (t !== '合计') ? (parseInt(index) + 1) : t
} }
}, },
{title: '库存详情', dataIndex: 'action', align:"center", width: 60,
scopedSlots: { customRender: 'action' }
},
{title: '图片', dataIndex: 'pic', width: 45, scopedSlots: { customRender: 'customPic' }}, {title: '图片', dataIndex: 'pic', width: 45, scopedSlots: { customRender: 'customPic' }},
{title: '条码', dataIndex: 'barCode', sorter: (a, b) => a.barCode - b.barCode, width: 100}, {title: '条码', dataIndex: 'barCode', sorter: (a, b) => a.barCode - b.barCode, width: 100},
{title: '名称', dataIndex: 'materialName', width: 120, ellipsis:true}, {title: '名称', dataIndex: 'materialName', width: 120, ellipsis:true},
@@ -312,6 +321,15 @@
this.getTotalCountMoney(); this.getTotalCountMoney();
} }
}, },
showMaterialDepotStockList(record) {
let depotIds = ''
if(this.depotSelected && this.depotSelected.length>0) {
depotIds = this.depotSelected.join()
}
this.$refs.materialDepotStockListWithTime.show(record, depotIds, this.queryParam.beginTime, this.queryParam.endTime);
this.$refs.materialDepotStockListWithTime.title = "查看进销存统计库存分布条码" + record.barCode + "名称" + record.materialName + "";
this.$refs.materialDepotStockListWithTime.disableSubmit = false;
},
exportExcel() { exportExcel() {
let list = [] let list = []
let mpStr = getMpListShort(Vue.ls.get('materialPropertyList')) let mpStr = getMpListShort(Vue.ls.get('materialPropertyList'))

View File

@@ -111,6 +111,8 @@
</span> </span>
<span slot="action" slot-scope="text, record"> <span slot="action" slot-scope="text, record">
<a @click="showMaterialInOutList(record)">{{record.id?'流水':''}}</a> <a @click="showMaterialInOutList(record)">{{record.id?'流水':''}}</a>
<a-divider type="vertical" />
<a @click="showMaterialDepotStockList(record)">{{record.id?'分布':''}}</a>
</span> </span>
<template slot="customPic" slot-scope="text, record"> <template slot="customPic" slot-scope="text, record">
<a-popover placement="right" trigger="click"> <a-popover placement="right" trigger="click">
@@ -148,12 +150,14 @@
</section> </section>
<!-- table区域-end --> <!-- table区域-end -->
<material-in-out-list ref="materialInOutList" @ok="modalFormOk"></material-in-out-list> <material-in-out-list ref="materialInOutList" @ok="modalFormOk"></material-in-out-list>
<material-depot-stock-list ref="materialDepotStockList" @ok="modalFormOk"></material-depot-stock-list>
</a-card> </a-card>
</a-col> </a-col>
</a-row> </a-row>
</template> </template>
<script> <script>
import MaterialInOutList from './modules/MaterialInOutList' import MaterialInOutList from './modules/MaterialInOutList'
import MaterialDepotStockList from './modules/MaterialDepotStockList'
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, getFileAccessHttpUrl } from '@/api/manage' import { getAction, getFileAccessHttpUrl } from '@/api/manage'
import {queryMaterialCategoryTreeList} from '@/api/api' import {queryMaterialCategoryTreeList} from '@/api/api'
@@ -166,6 +170,7 @@
mixins:[JeecgListMixin], mixins:[JeecgListMixin],
components: { components: {
MaterialInOutList, MaterialInOutList,
MaterialDepotStockList,
JEllipsis JEllipsis
}, },
data () { data () {
@@ -207,7 +212,7 @@
return (t !== '合计') ? (parseInt(index) + 1) : t return (t !== '合计') ? (parseInt(index) + 1) : t
} }
}, },
{title: '库存流水', dataIndex: 'action', align:"center", width: 60, {title: '库存详情', dataIndex: 'action', align:"center", width: 80,
scopedSlots: { customRender: 'action' } scopedSlots: { customRender: 'action' }
}, },
{title: '图片', dataIndex: 'pic', width: 45, scopedSlots: { customRender: 'customPic' }}, {title: '图片', dataIndex: 'pic', width: 45, scopedSlots: { customRender: 'customPic' }},
@@ -317,6 +322,15 @@
this.$refs.materialInOutList.title = "查看商品库存流水"; this.$refs.materialInOutList.title = "查看商品库存流水";
this.$refs.materialInOutList.disableSubmit = false; this.$refs.materialInOutList.disableSubmit = false;
}, },
showMaterialDepotStockList(record) {
let depotIds = ''
if(this.depotSelected && this.depotSelected.length>0) {
depotIds = this.depotSelected.join()
}
this.$refs.materialDepotStockList.show(record, depotIds);
this.$refs.materialDepotStockList.title = "查看商品库存分布条码" + record.mBarCode + "名称" + record.name + "";
this.$refs.materialDepotStockList.disableSubmit = false;
},
exportExcel() { exportExcel() {
let list = [] let list = []
let head = '条码,名称,规格,型号,颜色,品牌,制造商,类别,单位,成本价,初始库存,库存,库存金额,重量' let head = '条码,名称,规格,型号,颜色,品牌,制造商,类别,单位,成本价,初始库存,库存,库存金额,重量'

View File

@@ -0,0 +1,126 @@
<template>
<div ref="container">
<a-modal
:title="title"
:width="800"
:visible="visible"
:getContainer="() => $refs.container"
:maskStyle="{'top':'93px','left':'154px'}"
:wrapClassName="wrapClassNameInfo()"
:mask="isDesktop()"
:maskClosable="false"
@cancel="handleCancel"
cancelText="关闭"
style="top:100px;height: 80%;">
<template slot="footer">
<a-button key="back" @click="handleCancel">取消(ESC)</a-button>
</template>
<!-- table区域-begin -->
<a-table
bordered
ref="table"
size="middle"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:components="handleDrag(columns)"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange">
</a-table>
<!-- table区域-end -->
</a-modal>
</div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import { mixinDevice } from '@/utils/mixin'
export default {
name: "MaterialDepotStockList",
mixins:[JeecgListMixin, mixinDevice],
components: {
JEllipsis
},
data () {
return {
title:"操作",
visible: false,
disableMixinCreated: true,
toFromType: '',
currentMaterialId: '',
// 查询条件
queryParam: {
depotIds: '',
materialId:'',
},
ipagination:{
pageSizeOptions: ['10', '20', '30', '100', '200']
},
tabKey: "1",
// 表头
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:40,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{ title: '仓库名称', dataIndex: 'depotName', width: 200},
{ title: '库存数量', dataIndex: 'currentNumber', width: 100},
{ title: '成本价', dataIndex: 'unitPrice', width: 100},
{ title: '库存金额', dataIndex: 'allPrice', width: 100}
],
labelCol: {
xs: { span: 1 },
sm: { span: 2 },
},
wrapperCol: {
xs: { span: 10 },
sm: { span: 16 },
},
url: {
list: "/material/getMaterialDepotStock"
}
}
},
created() {
},
methods: {
getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter)
param.field = this.getQueryField()
param.materialId = this.currentMaterialId
param.currentPage = this.ipagination.current
param.pageSize = this.ipagination.pageSize
return param
},
show(record, depotIds) {
this.model = Object.assign({}, record);
this.currentMaterialId = record.id
this.visible = true;
this.queryParam.depotIds = depotIds
this.queryParam.materialId = record.id
this.loadData(1)
},
close () {
this.$emit('close');
this.visible = false;
},
handleCancel () {
this.close()
},
onDateOk(value) {
console.log(value);
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>

View File

@@ -0,0 +1,132 @@
<template>
<div ref="container">
<a-modal
:title="title"
:width="800"
:visible="visible"
:getContainer="() => $refs.container"
:maskStyle="{'top':'93px','left':'154px'}"
:wrapClassName="wrapClassNameInfo()"
:mask="isDesktop()"
:maskClosable="false"
@cancel="handleCancel"
cancelText="关闭"
style="top:100px;height: 80%;">
<template slot="footer">
<a-button key="back" @click="handleCancel">取消(ESC)</a-button>
</template>
<!-- table区域-begin -->
<a-table
bordered
ref="table"
size="middle"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:components="handleDrag(columns)"
pagination="false"
:loading="loading"
@change="handleTableChange">
</a-table>
<!-- table区域-end -->
</a-modal>
</div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import { mixinDevice } from '@/utils/mixin'
export default {
name: "MaterialDepotStockListWithTime",
mixins:[JeecgListMixin, mixinDevice],
components: {
JEllipsis
},
data () {
return {
title:"操作",
visible: false,
disableMixinCreated: true,
toFromType: '',
currentMaterialId: '',
// 查询条件
queryParam: {
depotIds: '',
materialId:'',
unitPrice:'',
beginTime:'',
endTime:'',
},
ipagination:{
pageSizeOptions: ['10', '20', '30', '100', '200']
},
tabKey: "1",
// 表头
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:40,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{ title: '仓库名称', dataIndex: 'depotName', width: 200},
{ title: '库存数量', dataIndex: 'currentNumber', width: 100},
{ title: '成本价', dataIndex: 'unitPrice', width: 100},
{ title: '库存金额', dataIndex: 'allPrice', width: 100}
],
labelCol: {
xs: { span: 1 },
sm: { span: 2 },
},
wrapperCol: {
xs: { span: 10 },
sm: { span: 16 },
},
url: {
list: "/depotItem/getMaterialDepotStockByParam"
}
}
},
created() {
},
methods: {
getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter)
param.field = this.getQueryField()
param.materialId = this.currentMaterialId
param.currentPage = this.ipagination.current
param.pageSize = this.ipagination.pageSize
return param
},
show(record, depotIds, beginTime, endTime) {
this.model = Object.assign({}, record);
this.currentMaterialId = record.id
this.visible = true;
this.queryParam.depotIds = depotIds
this.queryParam.materialId = record.id
this.queryParam.unitPrice = record.unitPrice
this.queryParam.beginTime = beginTime
this.queryParam.endTime = endTime
this.loadData(1)
},
close () {
this.$emit('close');
this.visible = false;
},
handleCancel () {
this.close()
},
onDateOk(value) {
console.log(value);
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>