1、仓库库存功能实现
This commit is contained in:
parent
28b064ba8e
commit
77e3e32585
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
|
width="500px"
|
||||||
:title="!dataForm.id ? '新增' : '修改'"
|
:title="!dataForm.id ? '新增' : '修改'"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
|
|
@ -9,10 +10,10 @@
|
||||||
:rules="dataRule"
|
:rules="dataRule"
|
||||||
ref="dataForm"
|
ref="dataForm"
|
||||||
@keyup.enter.native="dataFormSubmit()"
|
@keyup.enter.native="dataFormSubmit()"
|
||||||
label-width="120px"
|
label-width="90px"
|
||||||
>
|
>
|
||||||
<el-form-item label="sku_id" prop="skuId">
|
<el-form-item label="sku_id" prop="skuId">
|
||||||
<el-input v-model="dataForm.skuId" placeholder="sku_id"></el-input>
|
<el-input v-model="dataForm.skuId" placeholder="请输入商品id"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="仓库" prop="wareId">
|
<el-form-item label="仓库" prop="wareId">
|
||||||
<el-select v-model="dataForm.wareId" placeholder="请选择仓库" clearable>
|
<el-select v-model="dataForm.wareId" placeholder="请选择仓库" clearable>
|
||||||
|
|
@ -20,13 +21,13 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="库存数" prop="stock">
|
<el-form-item label="库存数" prop="stock">
|
||||||
<el-input v-model="dataForm.stock" placeholder="库存数"></el-input>
|
<el-input-number v-model.number="dataForm.stock" :min="0" :max="9999999" label="库存数"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="sku_name" prop="skuName">
|
<el-form-item label="sku_name" prop="skuName">
|
||||||
<el-input v-model="dataForm.skuName" placeholder="sku_name"></el-input>
|
<el-input v-model="dataForm.skuName" placeholder="请输入商品名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="锁定库存" prop="stockLocked">
|
<el-form-item label="锁定库存" prop="stockLocked">
|
||||||
<el-input v-model="dataForm.stockLocked" placeholder="锁定库存"></el-input>
|
<el-input-number v-model.number="dataForm.stockLocked" :min="0" :max="9999999" label="锁定库存"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
|
|
@ -37,7 +38,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
||||||
|
import {editWareSku, getWareSku, saveWareSku} from "@/api/mall/ware/ware-sku";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: "WareSku-add-or-update",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
@ -51,87 +56,64 @@ export default {
|
||||||
stockLocked: 0
|
stockLocked: 0
|
||||||
},
|
},
|
||||||
dataRule: {
|
dataRule: {
|
||||||
skuId: [{ required: true, message: "sku_id不能为空", trigger: "blur" }],
|
skuId: [{required: true, message: "sku_id不能为空", trigger: "blur"}],
|
||||||
wareId: [
|
wareId: [
|
||||||
{ required: true, message: "仓库id不能为空", trigger: "blur" }
|
{required: true, message: "仓库id不能为空", trigger: "blur"}
|
||||||
],
|
],
|
||||||
stock: [{ required: true, message: "库存数不能为空", trigger: "blur" }],
|
stock: [{required: true, message: "库存数不能为空", trigger: "blur"}],
|
||||||
skuName: [
|
skuName: [
|
||||||
{ required: true, message: "sku_name不能为空", trigger: "blur" }
|
{required: true, message: "sku_name不能为空", trigger: "blur"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created(){
|
created() {
|
||||||
this.getWares();
|
this.getWares();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//获取仓库信息
|
||||||
getWares() {
|
getWares() {
|
||||||
this.$http({
|
let params = {
|
||||||
url: this.$http.adornUrl("/ware/wareinfo/list"),
|
page: 1,
|
||||||
method: "get",
|
limit: 500
|
||||||
params: this.$http.adornParams({
|
}
|
||||||
page: 1,
|
getWareInfoList(params).then(res => {
|
||||||
limit: 500
|
this.wareList = res.page.list;
|
||||||
})
|
})
|
||||||
}).then(({ data }) => {
|
|
||||||
this.wareList = data.page.list;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
init(id) {
|
init(id) {
|
||||||
this.dataForm.id = id || 0;
|
this.dataForm.id = id;
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs["dataForm"].resetFields();
|
this.$refs["dataForm"].resetFields();
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
this.$http({
|
getWareSku(this.dataForm.id).then(res => {
|
||||||
url: this.$http.adornUrl(`/ware/waresku/info/${this.dataForm.id}`),
|
this.dataForm = res.wareSku
|
||||||
method: "get",
|
})
|
||||||
params: this.$http.adornParams()
|
|
||||||
}).then(({ data }) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.dataForm.skuId = data.wareSku.skuId;
|
|
||||||
this.dataForm.wareId = data.wareSku.wareId;
|
|
||||||
this.dataForm.stock = data.wareSku.stock;
|
|
||||||
this.dataForm.skuName = data.wareSku.skuName;
|
|
||||||
this.dataForm.stockLocked = data.wareSku.stockLocked;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 表单提交
|
// 表单提交
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
this.$refs["dataForm"].validate(valid => {
|
this.$refs["dataForm"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$http({
|
|
||||||
url: this.$http.adornUrl(
|
if (!this.dataForm.id) {
|
||||||
`/ware/waresku/${!this.dataForm.id ? "save" : "update"}`
|
saveWareSku(this.dataForm).then(res => {
|
||||||
),
|
this.$modal.notifySuccess("保存成功")
|
||||||
method: "post",
|
this.visible = false;
|
||||||
data: this.$http.adornData({
|
this.$emit("refreshDataList");
|
||||||
id: this.dataForm.id || undefined,
|
|
||||||
skuId: this.dataForm.skuId,
|
|
||||||
wareId: this.dataForm.wareId,
|
|
||||||
stock: this.dataForm.stock,
|
|
||||||
skuName: this.dataForm.skuName,
|
|
||||||
stockLocked: this.dataForm.stockLocked
|
|
||||||
})
|
})
|
||||||
}).then(({ data }) => {
|
} else {
|
||||||
if (data && data.code === 0) {
|
editWareSku(this.dataForm).then(res => {
|
||||||
this.$message({
|
this.$modal.notifySuccess("修改成功")
|
||||||
message: "操作成功",
|
this.visible = false;
|
||||||
type: "success",
|
this.$emit("refreshDataList");
|
||||||
duration: 1500,
|
})
|
||||||
onClose: () => {
|
}
|
||||||
this.visible = false;
|
|
||||||
this.$emit("refreshDataList");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$message.error(data.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="deleteHandle()"
|
@click="deleteHandle()"
|
||||||
:disabled="dataListSelections.length <= 0"
|
:disabled="dataListSelections.length <= 0"
|
||||||
>批量删除</el-button>
|
>批量删除
|
||||||
|
</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
@ -31,7 +33,7 @@
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||||
<el-table-column prop="skuId" header-align="center" align="center" label="sku_id"></el-table-column>
|
<el-table-column prop="skuId" header-align="center" align="center" label="sku_id"></el-table-column>
|
||||||
<el-table-column prop="wareId" header-align="center" align="center" label="仓库id"></el-table-column>
|
<el-table-column prop="wareName" header-align="center" align="center" label="仓库名称"></el-table-column>
|
||||||
<el-table-column prop="stock" header-align="center" align="center" label="库存数"></el-table-column>
|
<el-table-column prop="stock" header-align="center" align="center" label="库存数"></el-table-column>
|
||||||
<el-table-column prop="skuName" header-align="center" align="center" label="商品名称"></el-table-column>
|
<el-table-column prop="skuName" header-align="center" align="center" label="商品名称"></el-table-column>
|
||||||
<el-table-column prop="stockLocked" header-align="center" align="center" label="锁定库存"></el-table-column>
|
<el-table-column prop="stockLocked" header-align="center" align="center" label="锁定库存"></el-table-column>
|
||||||
|
|
@ -58,8 +60,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AddOrUpdate from "./waresku-add-or-update";
|
import AddOrUpdate from "./waresku-add-or-update";
|
||||||
|
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
||||||
|
import {delWareSku, getWareSkuList} from "@/api/mall/ware/ware-sku";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name:"WareSku",
|
name: "WareSku",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
wareList: [],
|
wareList: [],
|
||||||
|
|
@ -80,7 +85,6 @@ export default {
|
||||||
AddOrUpdate
|
AddOrUpdate
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
console.log("接收到", this.$route.query.skuId);
|
|
||||||
if (this.$route.query.skuId) {
|
if (this.$route.query.skuId) {
|
||||||
this.dataForm.skuId = this.$route.query.skuId;
|
this.dataForm.skuId = this.$route.query.skuId;
|
||||||
}
|
}
|
||||||
|
|
@ -88,41 +92,34 @@ export default {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//获取仓库信息
|
||||||
getWares() {
|
getWares() {
|
||||||
this.$http({
|
let params = {
|
||||||
url: this.$http.adornUrl("/ware/wareinfo/list"),
|
page: 1,
|
||||||
method: "get",
|
limit: 500
|
||||||
params: this.$http.adornParams({
|
}
|
||||||
page: 1,
|
getWareInfoList(params).then(res => {
|
||||||
limit: 500
|
this.wareList = res.page.list;
|
||||||
})
|
})
|
||||||
}).then(({ data }) => {
|
|
||||||
this.wareList = data.page.list;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
this.$http({
|
let params = {
|
||||||
url: this.$http.adornUrl("/ware/waresku/list"),
|
page: this.pageIndex,
|
||||||
method: "get",
|
limit: this.pageSize,
|
||||||
params: this.$http.adornParams({
|
skuId: this.dataForm.skuId,
|
||||||
page: this.pageIndex,
|
wareId: this.dataForm.wareId
|
||||||
limit: this.pageSize,
|
}
|
||||||
skuId: this.dataForm.skuId,
|
getWareSkuList(params).then(res => {
|
||||||
wareId: this.dataForm.wareId
|
this.dataList = res.page.list;
|
||||||
})
|
this.totalPage = res.page.totalCount;
|
||||||
}).then(({ data }) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.dataList = data.page.list;
|
|
||||||
this.totalPage = data.page.totalCount;
|
|
||||||
} else {
|
|
||||||
this.dataList = [];
|
|
||||||
this.totalPage = 0;
|
|
||||||
}
|
|
||||||
this.dataListLoading = false;
|
this.dataListLoading = false;
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// 每页数
|
// 每页数
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
this.pageSize = val;
|
this.pageSize = val;
|
||||||
|
|
@ -147,11 +144,9 @@ export default {
|
||||||
},
|
},
|
||||||
// 删除
|
// 删除
|
||||||
deleteHandle(id) {
|
deleteHandle(id) {
|
||||||
var ids = id
|
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||||
? [id]
|
return item.id;
|
||||||
: this.dataListSelections.map(item => {
|
});
|
||||||
return item.id;
|
|
||||||
});
|
|
||||||
this.$confirm(
|
this.$confirm(
|
||||||
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
||||||
"提示",
|
"提示",
|
||||||
|
|
@ -161,26 +156,21 @@ export default {
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}
|
}
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.$http({
|
|
||||||
url: this.$http.adornUrl("/ware/waresku/delete"),
|
delWareSku(ids).then(res => {
|
||||||
method: "post",
|
this.$modal.notifySuccess("删除成功")
|
||||||
data: this.$http.adornData(ids, false)
|
this.getDataList();
|
||||||
}).then(({ data }) => {
|
})
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.$message({
|
|
||||||
message: "操作成功",
|
|
||||||
type: "success",
|
|
||||||
duration: 1500,
|
|
||||||
onClose: () => {
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$message.error(data.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dataForm = {}
|
||||||
|
this.pageIndex = 1;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
package com.xjs.mall.ware.controller;
|
package com.xjs.mall.ware.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -11,16 +15,16 @@ import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 采购需求
|
||||||
*
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @email 1294405880@qq.com
|
* @email 1294405880@qq.com
|
||||||
* @date 2022-03-15 09:56:19
|
* @since 2022-03-15 09:56:19
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("ware/purchasedetail")
|
@RequestMapping("ware/purchasedetail")
|
||||||
|
@Api(tags = "商城-仓库-采购需求")
|
||||||
public class PurchaseDetailController {
|
public class PurchaseDetailController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseDetailService purchaseDetailService;
|
private PurchaseDetailService purchaseDetailService;
|
||||||
|
|
@ -28,8 +32,9 @@ public class PurchaseDetailController {
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@GetMapping("/list")
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
@ApiOperation("列表")
|
||||||
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
PageUtils page = purchaseDetailService.queryPage(params);
|
PageUtils page = purchaseDetailService.queryPage(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
|
|
@ -40,8 +45,9 @@ public class PurchaseDetailController {
|
||||||
* 信息
|
* 信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{id}")
|
@RequestMapping("/info/{id}")
|
||||||
public R info(@PathVariable("id") Long id){
|
@ApiOperation("信息")
|
||||||
PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id);
|
public R info(@PathVariable("id") Long id) {
|
||||||
|
PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id);
|
||||||
|
|
||||||
return R.ok().put("purchaseDetail", purchaseDetail);
|
return R.ok().put("purchaseDetail", purchaseDetail);
|
||||||
}
|
}
|
||||||
|
|
@ -50,8 +56,10 @@ public class PurchaseDetailController {
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
public R save(@RequestBody PurchaseDetailEntity purchaseDetail){
|
@ApiOperation("保存")
|
||||||
purchaseDetailService.save(purchaseDetail);
|
@Log(title = "采购需求", businessType = BusinessType.INSERT)
|
||||||
|
public R save(@RequestBody PurchaseDetailEntity purchaseDetail) {
|
||||||
|
purchaseDetailService.save(purchaseDetail);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
@ -60,8 +68,10 @@ public class PurchaseDetailController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
public R update(@RequestBody PurchaseDetailEntity purchaseDetail){
|
@ApiOperation("修改")
|
||||||
purchaseDetailService.updateById(purchaseDetail);
|
@Log(title = "采购需求", businessType = BusinessType.UPDATE)
|
||||||
|
public R update(@RequestBody PurchaseDetailEntity purchaseDetail) {
|
||||||
|
purchaseDetailService.updateById(purchaseDetail);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
@ -70,8 +80,10 @@ public class PurchaseDetailController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
public R delete(@RequestBody Long[] ids){
|
@ApiOperation("删除")
|
||||||
purchaseDetailService.removeByIds(Arrays.asList(ids));
|
@Log(title = "采购需求", businessType = BusinessType.DELETE)
|
||||||
|
public R delete(@RequestBody Long[] ids) {
|
||||||
|
purchaseDetailService.removeByIds(Arrays.asList(ids));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.xjs.mall.ware.controller;
|
package com.xjs.mall.ware.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.xjs.business.api.domain.Area;
|
import com.xjs.business.api.domain.Area;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
import com.xjs.mall.ware.entity.WareInfoEntity;
|
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||||
|
|
@ -76,6 +78,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
|
@Log(title = "仓库信息", businessType = BusinessType.INSERT)
|
||||||
public R save(@Validated(AddGroup.class) @RequestBody WareInfoEntity wareInfo) {
|
public R save(@Validated(AddGroup.class) @RequestBody WareInfoEntity wareInfo) {
|
||||||
wareInfoService.save(wareInfo);
|
wareInfoService.save(wareInfo);
|
||||||
|
|
||||||
|
|
@ -87,6 +90,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
||||||
*/
|
*/
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
|
@Log(title = "仓库信息", businessType = BusinessType.UPDATE)
|
||||||
public R update(@Validated(UpdateGroup.class)@RequestBody WareInfoEntity wareInfo) {
|
public R update(@Validated(UpdateGroup.class)@RequestBody WareInfoEntity wareInfo) {
|
||||||
wareInfoService.updateById(wareInfo);
|
wareInfoService.updateById(wareInfo);
|
||||||
|
|
||||||
|
|
@ -98,6 +102,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@ApiOperation("删除")
|
@ApiOperation("删除")
|
||||||
|
@Log(title = "仓库信息", businessType = BusinessType.DELETE)
|
||||||
public R delete(@RequestBody Long[] ids) {
|
public R delete(@RequestBody Long[] ids) {
|
||||||
wareInfoService.removeByIds(Arrays.asList(ids));
|
wareInfoService.removeByIds(Arrays.asList(ids));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,29 @@
|
||||||
package com.xjs.mall.ware.controller;
|
package com.xjs.mall.ware.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||||
import com.xjs.mall.ware.service.WareSkuService;
|
import com.xjs.mall.ware.service.WareSkuService;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
import com.xjs.mall.other.R;
|
||||||
|
import com.xjs.validation.group.AddGroup;
|
||||||
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品库存
|
* 商品库存
|
||||||
*
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @email 1294405880@qq.com
|
* @email 1294405880@qq.com
|
||||||
* @since 2022-03-15 09:56:19
|
* @since 2022-03-15 09:56:19
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("ware/waresku")
|
@RequestMapping("ware/waresku")
|
||||||
|
|
@ -33,7 +37,7 @@ public class WareSkuController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("列表")
|
@ApiOperation("列表")
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
PageUtils page = wareSkuService.queryPage(params);
|
PageUtils page = wareSkuService.queryPage(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
|
|
@ -43,10 +47,10 @@ public class WareSkuController {
|
||||||
/**
|
/**
|
||||||
* 信息
|
* 信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{id}")
|
@GetMapping("/info/{id}")
|
||||||
@ApiOperation("信息")
|
@ApiOperation("信息")
|
||||||
public R info(@PathVariable("id") Long id){
|
public R info(@PathVariable("id") Long id) {
|
||||||
WareSkuEntity wareSku = wareSkuService.getById(id);
|
WareSkuEntity wareSku = wareSkuService.getById(id);
|
||||||
|
|
||||||
return R.ok().put("wareSku", wareSku);
|
return R.ok().put("wareSku", wareSku);
|
||||||
}
|
}
|
||||||
|
|
@ -54,10 +58,11 @@ public class WareSkuController {
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@PostMapping("/save")
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
public R save(@RequestBody WareSkuEntity wareSku){
|
@Log(title = "商品库存", businessType = BusinessType.INSERT)
|
||||||
wareSkuService.save(wareSku);
|
public R save(@Validated(AddGroup.class) @RequestBody WareSkuEntity wareSku) {
|
||||||
|
wareSkuService.save(wareSku);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
@ -65,10 +70,11 @@ public class WareSkuController {
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@PutMapping("/update")
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
public R update(@RequestBody WareSkuEntity wareSku){
|
@Log(title = "商品库存", businessType = BusinessType.UPDATE)
|
||||||
wareSkuService.updateById(wareSku);
|
public R update(@Validated(UpdateGroup.class) @RequestBody WareSkuEntity wareSku) {
|
||||||
|
wareSkuService.updateById(wareSku);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
@ -76,10 +82,11 @@ public class WareSkuController {
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@ApiOperation("删除")
|
@ApiOperation("删除")
|
||||||
public R delete(@RequestBody Long[] ids){
|
@Log(title = "商品库存", businessType = BusinessType.DELETE)
|
||||||
wareSkuService.removeByIds(Arrays.asList(ids));
|
public R delete(@RequestBody Long[] ids) {
|
||||||
|
wareSkuService.removeByIds(Arrays.asList(ids));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,19 @@ package com.xjs.mall.ware.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.xjs.validation.group.AddGroup;
|
||||||
import java.io.Serializable;
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
import java.util.Date;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品库存
|
* 商品库存
|
||||||
*
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @email 1294405880@qq.com
|
* @email 1294405880@qq.com
|
||||||
* @date 2022-03-15 09:56:19
|
* @date 2022-03-15 09:56:19
|
||||||
|
|
@ -17,32 +22,41 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
@TableName("wms_ware_sku")
|
@TableName("wms_ware_sku")
|
||||||
public class WareSkuEntity implements Serializable {
|
public class WareSkuEntity implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* sku_id
|
* sku_id
|
||||||
*/
|
*/
|
||||||
private Long skuId;
|
@NotNull(message = "sku_id不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
/**
|
private Long skuId;
|
||||||
* 仓库id
|
/**
|
||||||
*/
|
* 仓库id
|
||||||
private Long wareId;
|
*/
|
||||||
/**
|
@NotNull(message = "仓库id不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
* 库存数
|
private Long wareId;
|
||||||
*/
|
/**
|
||||||
private Integer stock;
|
* 库存数
|
||||||
/**
|
*/
|
||||||
* sku_name
|
@NotNull(message = "库存数不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
*/
|
@Min(value = 0,message = "库存不能小于零",groups = {AddGroup.class,UpdateGroup.class})
|
||||||
private String skuName;
|
@Max(value = 9999999,message = "库存不能大于9999999",groups = {AddGroup.class,UpdateGroup.class})
|
||||||
/**
|
private Integer stock;
|
||||||
* 锁定库存
|
/**
|
||||||
*/
|
* sku_name
|
||||||
private Integer stockLocked;
|
*/
|
||||||
|
@NotBlank(message = "sku_name不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
|
private String skuName;
|
||||||
|
/**
|
||||||
|
* 锁定库存
|
||||||
|
*/
|
||||||
|
@NotNull(message = "锁定库存不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
|
@Min(value = 0,message = "锁定库存不能小于零",groups = {AddGroup.class,UpdateGroup.class})
|
||||||
|
@Max(value = 9999999,message = "锁定库存不能大于9999999",groups = {AddGroup.class,UpdateGroup.class})
|
||||||
|
private Integer stockLocked;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package com.xjs.mall.ware.service.impl;
|
package com.xjs.mall.ware.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.xjs.mall.ware.dao.PurchaseDetailDao;
|
import com.xjs.mall.ware.dao.PurchaseDetailDao;
|
||||||
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||||
|
|
@ -18,12 +19,23 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailDao, Pu
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<PurchaseDetailEntity> page = this.page(
|
LambdaQueryWrapper<PurchaseDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
new Query<PurchaseDetailEntity>().getPage(params),
|
|
||||||
new QueryWrapper<PurchaseDetailEntity>()
|
String key = (String) params.get(Query.KEY_NAME);
|
||||||
);
|
String status = (String) params.get("status");
|
||||||
|
String wareId = (String) params.get("wareId");
|
||||||
|
|
||||||
|
wrapper.and(StringUtils.isNotEmpty(key), w -> {
|
||||||
|
w.eq(PurchaseDetailEntity::getPurchaseId, key)
|
||||||
|
.or()
|
||||||
|
.eq(PurchaseDetailEntity::getSkuId, key);
|
||||||
|
})
|
||||||
|
.eq(StringUtils.isNotEmpty(status), PurchaseDetailEntity::getStatus, status)
|
||||||
|
.eq(StringUtils.isNotEmpty(wareId), PurchaseDetailEntity::getWareId, wareId);
|
||||||
|
|
||||||
|
IPage<PurchaseDetailEntity> page = this.page(new Query<PurchaseDetailEntity>().getPage(params), wrapper);
|
||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,33 +4,55 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||||
import com.xjs.mall.ware.dao.WareSkuDao;
|
import com.xjs.mall.ware.dao.WareSkuDao;
|
||||||
|
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||||
|
import com.xjs.mall.ware.service.WareInfoService;
|
||||||
import com.xjs.mall.ware.service.WareSkuService;
|
import com.xjs.mall.ware.service.WareSkuService;
|
||||||
|
import com.xjs.mall.ware.vo.WareSkuVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.utils.Query;
|
import com.xjs.utils.Query;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("wareSkuService")
|
@Service("wareSkuService")
|
||||||
public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService {
|
public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WareInfoService wareInfoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
LambdaQueryWrapper<WareSkuEntity> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WareSkuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
String key = (String) params.get(Query.KEY_NAME);
|
String key = (String) params.get(Query.KEY_NAME);
|
||||||
if (StringUtils.isNotEmpty(key)) {
|
String skuId = (String) params.get("skuId");
|
||||||
wrapper.eq(WareSkuEntity::getSkuName, key).or()
|
String wareId = (String) params.get("wareId");
|
||||||
.eq(WareSkuEntity::getSkuId, key).or()
|
wrapper.like(StringUtils.isNotEmpty(key), WareSkuEntity::getSkuName, key).or()
|
||||||
.eq(WareSkuEntity::getWareId, key);
|
.eq(StringUtils.isNotEmpty(skuId), WareSkuEntity::getSkuId, skuId).or()
|
||||||
}
|
.eq(StringUtils.isNotEmpty(wareId), WareSkuEntity::getWareId, wareId);
|
||||||
|
|
||||||
IPage<WareSkuEntity> page = this.page(new Query<WareSkuEntity>().getPage(params),wrapper);
|
IPage<WareSkuEntity> page = this.page(new Query<WareSkuEntity>().getPage(params), wrapper);
|
||||||
|
|
||||||
return new PageUtils(page);
|
List<Object> collect = page.getRecords().stream().map(wareSkuEntity -> {
|
||||||
|
WareSkuVo wareSkuVo = new WareSkuVo();
|
||||||
|
BeanUtils.copyProperties(wareSkuEntity,wareSkuVo);
|
||||||
|
//获取仓库信息
|
||||||
|
WareInfoEntity wareInfoEntity = wareInfoService.getById(wareSkuVo.getWareId());
|
||||||
|
wareSkuVo.setWareName(wareInfoEntity.getName());
|
||||||
|
return wareSkuVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
PageUtils pageUtils = new PageUtils(page);
|
||||||
|
pageUtils.setList(collect);
|
||||||
|
|
||||||
|
return pageUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.xjs.mall.ware.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品库存vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WareSkuVo {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* sku_id
|
||||||
|
*/
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* 仓库id
|
||||||
|
*/
|
||||||
|
private Long wareId;
|
||||||
|
/**
|
||||||
|
* 库存数
|
||||||
|
*/
|
||||||
|
private Integer stock;
|
||||||
|
/**
|
||||||
|
* sku_name
|
||||||
|
*/
|
||||||
|
private String skuName;
|
||||||
|
/**
|
||||||
|
* 锁定库存
|
||||||
|
*/
|
||||||
|
private Integer stockLocked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库名称
|
||||||
|
*/
|
||||||
|
private String wareName;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue