Commit c51d7cc8 authored by 刘帅's avatar 刘帅

1.优化

parent 0135a47b
......@@ -62,7 +62,6 @@ public class ErpMaterialPickingBo extends BaseEntity {
/**
* 供应商ID
*/
@NotNull(message = "供应商不能为空", groups = { AddGroup.class, EditGroup.class })
private Long vendorId;
/**
......
......@@ -56,12 +56,12 @@ public interface ErpMaterialInventoryRecordMapper extends BaseMapperPlus<ErpMate
/**
* 查询物料库存列表
*/
List<ErpMaterialInventoryRecordVo> queryListByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("materialId") Long materialId, @Param("type") String type);
List<ErpMaterialInventoryRecordVo> queryListByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("vendorId") Long vendorId, @Param("materialId") Long materialId, @Param("type") String type);
/**
* 根据仓库ID以及物料ID动态计算物料库存
* 根据仓库ID\供应商ID\物料ID动态计算物料库存
*/
ErpMaterialInventoryRecordVo queryMaterialByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("materialId") Long materialId);
ErpMaterialInventoryRecordVo queryMaterialByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("vendorId") Long vendorId, @Param("materialId") Long materialId);
}
......@@ -242,7 +242,7 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
/* 查询物料 */
ErpMaterial material = materialMapper.selectById(item.getMaterialId());
/* 查询物料库存 */
ErpMaterialInventoryRecordVo recordVo = materialInventoryRecordMapper.queryMaterialByWarehouseIdAndMaterialId(bo.getWarehouseId(), item.getMaterialId());
ErpMaterialInventoryRecordVo recordVo = materialInventoryRecordMapper.queryMaterialByWarehouseIdAndMaterialId(bo.getWarehouseId(), item.getVendorId(), item.getMaterialId());
/* 如果recordVo为空,说明改物料没有过库存变动记录数据,默认给0 */
BigDecimal inventory = new BigDecimal("0");
if (null != recordVo) {
......@@ -253,12 +253,14 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
ErpMaterialPutawayInfo putawayInfo = BeanUtil.toBean(material, ErpMaterialPutawayInfo.class);
putawayInfo.setPutawayNumber(item.getCheckNum().subtract(inventory));
putawayInfo.setMaterialId(item.getMaterialId());
putawayInfo.setVendorId(item.getVendorId());
putawayInfo.setId(null);
putawayInfoList.add(putawayInfo);
}else if (item.getResultState().equals(CheckInfoState.TWO.getCode())) {
ErpMaterialPickingInfo pickingInfo = BeanUtil.toBean(material, ErpMaterialPickingInfo.class);
pickingInfo.setCollectNumber(inventory.subtract(item.getCheckNum()));
pickingInfo.setMaterialId(item.getMaterialId());
pickingInfo.setVendorId(item.getVendorId());
pickingInfo.setId(null);
pickingInfoList.add(pickingInfo);
}
......@@ -272,6 +274,7 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
putaway.setState(PutawayState.TWO.getCode());
putaway.setWarehouseId(materialCheck.getWarehouseId());
putaway.setWarehouseName(materialCheck.getWarehouseName());
putaway.setCreateDeptId(LoginHelper.getDeptId());
materialPutawayMapper.insert(putaway);
materialPutawayInfoMapper.insertBatch(
putawayInfoList
......@@ -285,6 +288,7 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
record.setInfoId(item.getId());
record.setMaterialId(item.getMaterialId());
record.setWarehouseId(warehouse.getId());
record.setVendorId(item.getVendorId());
record.setDeptId(warehouse.getDeptId());
record.setNumber(item.getPutawayNumber());
record.setPrice(item.getPutawayPrice());
......@@ -301,6 +305,7 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
picking.setType(PickingType.TWO.getCode());
picking.setState(PickingState.TWO.getCode());
picking.setOutTime(new Date());
picking.setCreateDeptId(LoginHelper.getDeptId());
materialPickingMapper.insert(picking);
materialPickingInfoMapper.insertBatch(
pickingInfoList
......@@ -314,11 +319,12 @@ public class ErpMaterialCheckServiceImpl implements IErpMaterialCheckService {
record.setInfoId(item.getId());
record.setMaterialId(item.getMaterialId());
record.setWarehouseId(warehouse.getId());
record.setVendorId(item.getVendorId());
record.setDeptId(warehouse.getDeptId());
record.setNumber(item.getCollectNumber());
record.setPrice(item.getPrice());
record.setMoney(item.getMoney());
record.setType(InventoryType.putaway.getCode());
record.setType(InventoryType.picking.getCode());
return record;
}).collect(Collectors.toList())
);
......
......@@ -101,7 +101,7 @@ public class ErpMaterialInventoryRecordServiceImpl implements IErpMaterialInvent
*/
@Override
public List<ErpMaterialInventoryRecordVo> queryListByMaterialId(ErpMaterialInventoryRecordBo bo) {
return baseMapper.queryListByWarehouseIdAndMaterialId(bo.getWarehouseId(), bo.getMaterialId(), bo.getType());
return baseMapper.queryListByWarehouseIdAndMaterialId(bo.getWarehouseId(), bo.getVendorId(), bo.getMaterialId(), bo.getType());
}
private LambdaQueryWrapper<ErpMaterialInventoryRecord> buildQueryWrapper(ErpMaterialInventoryRecordBo bo) {
......
......@@ -104,7 +104,10 @@ public class ErpMaterialPickingServiceImpl implements IErpMaterialPickingService
LambdaQueryWrapper<ErpMaterialPutawayInfo> putawayInfoLambdaQueryWrapper = Wrappers.lambdaQuery();
putawayInfoLambdaQueryWrapper.eq(ErpMaterialPutawayInfo::getMaterialId, infoVo.getMaterialId());
List<ErpMaterialPutawayInfoVo> putawayInfoVos = putawayInfoMapper.selectVoList(putawayInfoLambdaQueryWrapper);
Set<BigDecimal> priceSet = putawayInfoVos.stream().map(ErpMaterialPutawayInfoVo::getPutawayPrice).collect(Collectors.toSet());
Set<BigDecimal> priceSet = putawayInfoVos.stream()
.map(ErpMaterialPutawayInfoVo::getPutawayPrice)
.filter(Objects::nonNull) // 排除 null 值
.collect(Collectors.toSet());
infoVo.setPriceList(priceSet);
}
pickingVo.setPickingInfoList(infoVoList);
......
......@@ -64,22 +64,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE type = '1'
GROUP BY warehouse_id, material_id, vendor_id) put
ON r.warehouse_id = put.warehouse_id AND r.material_id = put.material_id AND r.vendor_id = put.vendor_id
LEFT JOIN(SELECT warehouse_id, material_id, vendor_id, SUM(number) AS retNumber
LEFT JOIN(SELECT warehouse_id, vendor_id, material_id, SUM(number) AS retNumber
FROM erp_material_inventory_record
WHERE type = '2'
GROUP BY warehouse_id, material_id, vendor_id) ret
GROUP BY warehouse_id, vendor_id, material_id) ret
ON r.warehouse_id = ret.warehouse_id AND r.material_id = ret.material_id AND r.vendor_id = ret.vendor_id
LEFT JOIN(SELECT warehouse_id, material_id, vendor_id, SUM(number) AS picNumber
FROM erp_material_inventory_record
WHERE type = '3'
GROUP BY warehouse_id, material_id, vendor_id) pic
GROUP BY warehouse_id, vendor_id, material_id) pic
ON r.warehouse_id = pic.warehouse_id AND r.material_id = pic.material_id AND r.vendor_id = pic.vendor_id
LEFT JOIN(SELECT warehouse_id, material_id, vendor_id, SUM(number) AS bacNumber
FROM erp_material_inventory_record
WHERE type = '4'
GROUP BY warehouse_id, material_id, vendor_id) bac
GROUP BY warehouse_id, vendor_id, material_id) bac
ON r.warehouse_id = bac.warehouse_id AND r.material_id = bac.material_id AND r.vendor_id = bac.vendor_id
GROUP BY r.warehouse_id, r.material_id, r.vendor_id
GROUP BY r.warehouse_id, r.vendor_id, r.material_id
) t
</sql>
<sql id="list">
......@@ -175,7 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN erp_material_picking_info pi ON r.info_id = pi.id
LEFT JOIN erp_material_picking mp ON pi.picking_id = mp.id
</if>
WHERE r.warehouse_id = #{warehouseId} AND r.material_id = #{materialId} and r.type = #{type}
WHERE r.warehouse_id = #{warehouseId} AND r.vendor_id = #{vendorId} AND r.material_id = #{materialId} and r.type = #{type}
</select>
<select id="customQueryList" resultType="com.maintain.business.domain.vo.ErpMaterialInventoryRecordVo">
......@@ -185,7 +185,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryMaterialByWarehouseIdAndMaterialId"
resultType="com.maintain.business.domain.vo.ErpMaterialInventoryRecordVo">
<include refid="custom"/>
WHERE t.warehouse_id = #{warehouseId} AND t.material_id = #{materialId}
WHERE t.warehouse_id = #{warehouseId} AND t.vendor_id = #{vendorId} AND t.material_id = #{materialId}
</select>
<select id="customQueryInventoryById"
resultType="com.maintain.business.domain.vo.ErpMaterialInventoryRecordVo">
......
......@@ -103,53 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${ew.getCustomSqlSegment}
</select>
<select id="customQueryListByWarehouseId" resultType="com.maintain.business.domain.vo.ErpMaterialVo">
SELECT
m.id AS material_id,
m.material_code,
m.material_name,
m.material_specifications,
m.vendor_id,
m.vendor_name,
m.material_unit,
m.material_brand,
m.procurement_subject,
m.compatible_with,
m.material_warranty_period,
m.reference_price,
m.selling_price,
m.material_url,
IFNULL(put.putNumber, 0) - IFNULL(ret.retNumber, 0) - IFNULL(pic.picNumber, 0) + IFNULL(bac.bacNumber, 0) AS inventory
FROM
erp_material m
LEFT JOIN (
SELECT material_id, SUM(number) AS putNumber
FROM erp_material_inventory_record
WHERE type = '1' AND warehouse_id = #{warehouseId}
GROUP BY material_id
) put ON m.id = put.material_id
LEFT JOIN (
SELECT material_id, SUM(number) AS retNumber
FROM erp_material_inventory_record
WHERE type = '2' AND warehouse_id = #{warehouseId}
GROUP BY material_id
) ret ON m.id = ret.material_id
LEFT JOIN (
SELECT material_id, SUM(number) AS picNumber
FROM erp_material_inventory_record
WHERE type = '3' AND warehouse_id = #{warehouseId}
GROUP BY material_id
) pic ON m.id = pic.material_id
LEFT JOIN (
SELECT material_id, SUM(number) AS bacNumber
FROM erp_material_inventory_record
WHERE type = '4' AND warehouse_id = #{warehouseId}
GROUP BY material_id
) bac ON m.id = bac.material_id
WHERE
put.putNumber IS NOT NULL OR
ret.retNumber IS NOT NULL OR
pic.picNumber IS NOT NULL OR
bac.bacNumber IS NOT NULL
<include refid="customQuerySql" />
where t.warehouse_id = #{warehouseId}
</select>
......
......@@ -117,7 +117,7 @@
size="mini"
type="text"
icon="el-icon-edit"
:disabled="scope.row.state === 1"
:disabled="scope.row.checkState === 2"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:materialCheck:edit']"
>修改</el-button>
......@@ -125,7 +125,7 @@
size="mini"
type="text"
icon="el-icon-delete"
:disabled="scope.row.state === 1"
:disabled="scope.row.checkState === 2"
@click="handleDelete(scope.row)"
v-hasPermi="['business:materialCheck:remove']"
>删除</el-button>
......@@ -133,7 +133,7 @@
size="mini"
type="text"
icon="el-icon-check"
:disabled="scope.row.state === 1"
:disabled="scope.row.checkState === 2"
@click="handleCheck(scope.row)"
v-hasPermi="['business:materialCheck:check']"
>结束盘点</el-button>
......@@ -246,15 +246,16 @@
</el-row>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button v-loading="infoLoading" type="primary" plain icon="el-icon-plus" size="mini" @click="openMaterialModel">新增</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button v-loading="infoLoading" type="primary" plain icon="el-icon-plus" size="mini" @click="openMaterialModel">新增</el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button v-loading="infoLoading" type="primary" plain icon="el-icon-plus" size="mini" @click="openMaterialInit">初始化</el-button>
</el-col>
</el-row>
<el-divider />
<el-table v-loading="infoLoading" :data="form.checkInfoList">
<el-table-column label="供应商" align="center" prop="vendorName" />
<el-table-column label="物资编码" align="center" prop="materialCode" />
<el-table-column label="物资名称" align="center" prop="materialName" />
<el-table-column label="物资规格" align="center" prop="materialSpecifications" />
......@@ -263,7 +264,6 @@
<dict-tag :options="dict.type.material_unit" :value="scope.row.materialUnit" />
</template>
</el-table-column>
<el-table-column label="供应商" align="center" prop="vendorName" />
<el-table-column label="质保期" align="center" prop="materialWarrantyPeriod" />
<el-table-column label="库存" align="center" prop="inventory" />
<el-table-column label="实盘数量" align="center" prop="checkNum" width="140px">
......@@ -330,6 +330,7 @@
</el-form>
<el-table v-loading="materialLoading" :data="materialList" ref="selectionTable" max-height="450" row-key="materialId" @selection-change="handleMaterialSelectionChange">
<el-table-column type="selection" width="55" align="center" reserve-selection />
<el-table-column label="供应商" align="center" prop="vendorName" />
<el-table-column label="物资编码" align="center" prop="materialCode" />
<el-table-column label="物资名称" align="center" prop="materialName" />
<el-table-column label="物资规格" align="center" prop="materialSpecifications" />
......@@ -338,7 +339,6 @@
<dict-tag :options="dict.type.material_unit" :value="scope.row.materialUnit" />
</template>
</el-table-column>
<el-table-column label="供应商" align="center" prop="vendorName" />
<el-table-column label="质保期" align="center" prop="materialWarrantyPeriod" />
<el-table-column label="参考价" align="center" prop="referencePrice" />
<el-table-column label="销售价" align="center" prop="sellingPrice" />
......@@ -457,15 +457,16 @@ import {
addMaterialCheck,
delMaterialCheck,
getMaterialCheck,
listMaterialCheck, materialCheck,
listMaterialCheck,
materialCheck,
updateMaterialCheck
} from '@/api/business/materialCheck'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getCurrentDeptTree } from '@/api/business/unit'
import {listSiteWarehouse, listWarehouseAll} from '@/api/business/siteWarehouse'
import {customListAll, customListAllByWarehouseId, listMaterial} from '@/api/business/material'
import { formatDate } from '@/utils'
import {getCurrentDeptTree} from '@/api/business/unit'
import {listWarehouseAll} from '@/api/business/siteWarehouse'
import {customListAll, customListAllByWarehouseId} from '@/api/business/material'
import {formatDate} from '@/utils'
export default {
name: "MaterialCheck",
......@@ -605,13 +606,13 @@ export default {
},
// 仓库变更
warehouseChange(warehouseId) {
this.infoLoading = true
// this.infoLoading = true
this.form.checkInfoList = []
customListAll({ ...this.queryMaterialParams, warehouseId}).then(response => {
this.materialList = response.rows;
this.materialTotal = response.total;
this.infoLoading = false
});
// customListAll({ ...this.queryMaterialParams, warehouseId}).then(response => {
// this.materialList = response.rows;
// this.materialTotal = response.total;
// this.infoLoading = false
// });
},
// 盘点数量更改
checkNumChange() {
......@@ -747,8 +748,14 @@ export default {
},
/* 移除按钮操作 */
handleRowDelete(row) {
console.log('row', row);
this.form.checkInfoList = this.form.checkInfoList.filter(item =>{
return item.materialId !== row.materialId
console.log('item', item)
return !(
item.warehouseId === row.warehouseId &&
item.vendorId === row.vendorId &&
item.materialId === row.materialId
);
})
},
// 取消按钮
......
......@@ -718,6 +718,8 @@ export default {
this.form.carId = res.data.carId
this.open2 = true;
})
}else {
this.open2 = true;
}
});
},
......
......@@ -242,7 +242,7 @@
</el-table-column>
<el-table-column label="退货数量" align="center" prop="returnsNumber" width="120px">
<template slot-scope="scope">
<el-input-number v-model="scope.row.returnsNumber" @change="returnsNumberChange" controls-position="right" size="mini" :min="1" :max="scope.row.putawayNumber - scope.row.returnedNumber - scope.row.issuedNumber" :precision="0" style="width: 100%" placeholder="数量"/>
<el-input-number v-model="scope.row.returnsNumber" @change="returnsNumberChange" controls-position="right" size="mini" :min="0" :max="scope.row.putawayNumber - scope.row.returnedNumber - scope.row.issuedNumber" :precision="0" style="width: 100%" placeholder="数量"/>
</template>
</el-table-column>
<el-table-column label="退货单价" align="center" prop="returnsPrice" width="120px">
......@@ -511,6 +511,17 @@ export default {
if (valid) {
this.buttonLoading = true;
this.form.returnsInfoBoList = this.materialList
let isTrue = false;
this.form.returnsInfoBoList.forEach(item => {
if (item.returnsNumber < 1) {
isTrue = true;
}
})
if (isTrue) {
this.$modal.msgError('退货数量不能小于1')
this.buttonLoading = false;
return
}
if (this.form.id != null) {
updateMaterialReturns(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
......
......@@ -272,34 +272,34 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.open = true;
this.title = `物资${row.materialName}】库存记录`;
let {warehouseId, materialId, type} = row
this.getPutawayInfoList(warehouseId, materialId)
this.getReturnsInfoList(warehouseId, materialId)
this.getPickingInfoList(warehouseId, materialId)
this.getBackInfoList(warehouseId, materialId)
this.title = `${row.warehouseName}】【${row.vendorName}${row.materialName}】库存记录`;
let {warehouseId, vendorId, materialId, type} = row
this.getPutawayInfoList(warehouseId, vendorId, materialId)
this.getReturnsInfoList(warehouseId, vendorId, materialId)
this.getPickingInfoList(warehouseId, vendorId, materialId)
this.getBackInfoList(warehouseId, vendorId, materialId)
},
/** 查询物料入库明细列表 */
getPutawayInfoList(warehouseId, materialId) {
listByMaterialId({warehouseId, materialId, type: 1}).then(response => {
getPutawayInfoList(warehouseId, vendorId, materialId) {
listByMaterialId({warehouseId, vendorId, materialId, type: 1}).then(response => {
this.materialPutawayInfoList = response.data;
});
},
/** 查询物料退货明细列表 */
getReturnsInfoList(warehouseId, materialId) {
listByMaterialId({warehouseId, materialId, type: 2}).then(response => {
getReturnsInfoList(warehouseId, vendorId, materialId) {
listByMaterialId({warehouseId, vendorId, materialId, type: 2}).then(response => {
this.materialReturnsInfoList = response.data;
});
},
/** 查询物料出库列表 */
getPickingInfoList(warehouseId, materialId) {
listByMaterialId({warehouseId, materialId, type: 3}).then(response => {
getPickingInfoList(warehouseId, vendorId, materialId) {
listByMaterialId({warehouseId, vendorId, materialId, type: 3}).then(response => {
this.materialPickingInfoList = response.data;
});
},
/** 查询物料退料列表 */
getBackInfoList(warehouseId, materialId) {
listByMaterialId({warehouseId, materialId, type: 4}).then(response => {
getBackInfoList(warehouseId, vendorId, materialId) {
listByMaterialId({warehouseId, vendorId, materialId, type: 4}).then(response => {
this.materialBackInfoList = response.data;
});
},
......
......@@ -203,8 +203,8 @@
<el-table-column type="expand">
<template slot-scope="props">
<el-table :data="props.row.settlementMaterialInfoList">
<el-table-column label="分类名称" align="center" prop="materialTypeName" />
<el-table-column label="货位类型" align="center" prop="warehouseLocationType" />
<!-- <el-table-column label="分类名称" align="center" prop="materialTypeName" />-->
<!-- <el-table-column label="货位类型" align="center" prop="warehouseLocationType" />-->
<el-table-column label="供应商" align="center" prop="vendorName" />
<el-table-column label="物资编码" align="center" prop="materialCode" />
<el-table-column label="物资名称" align="center" prop="materialName" />
......@@ -253,7 +253,7 @@ import { listSettlementMaterial, getSettlementMaterial, delSettlementMaterial, a
export default {
name: "SettlementMaterial",
dicts: ['settlement_material_type', 'settlement_state','picking_state'],
dicts: ['settlement_material_type', 'settlement_state','picking_state', 'material_unit'],
data() {
return {
// 按钮loading
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment