1、仓库服务采购单合并功能实现
This commit is contained in:
parent
14163a7341
commit
ddc6927910
|
|
@ -44,4 +44,20 @@ export function editWarePurchase(data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//未领取采购单列表
|
||||||
|
export function unreceiveList(parms) {
|
||||||
|
return request({
|
||||||
|
url: '/mall-ware/ware/purchase/unreceive/list',
|
||||||
|
method: 'get',
|
||||||
|
params: parms
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//合并采购单
|
||||||
|
export function mergePurchase(data) {
|
||||||
|
return request({
|
||||||
|
url: '/mall-ware/ware/purchase/merge',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,16 @@
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
>
|
>
|
||||||
<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="assigneeId" header-align="center" align="center" label="采购人id" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="id" header-align="center" align="center" label="采购单id"
|
||||||
<el-table-column prop="assigneeName" header-align="center" align="center" label="采购人名" :show-overflow-tooltip="true"></el-table-column>
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="phone" header-align="center" align="center" label="联系方式" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="assigneeId" header-align="center" align="center" label="采购人id"
|
||||||
<el-table-column prop="priority" header-align="center" align="center" label="优先级" :show-overflow-tooltip="true"></el-table-column>
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
|
<el-table-column prop="assigneeName" header-align="center" align="center" label="采购人"
|
||||||
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
|
<el-table-column prop="phone" header-align="center" align="center" label="联系方式"
|
||||||
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
|
<el-table-column prop="priority" header-align="center" align="center" label="优先级"
|
||||||
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="status" header-align="center" align="center" label="状态">
|
<el-table-column prop="status" header-align="center" align="center" label="状态">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag v-if="scope.row.status === 0">新建</el-tag>
|
<el-tag v-if="scope.row.status === 0">新建</el-tag>
|
||||||
|
|
@ -56,18 +62,18 @@
|
||||||
<el-tag type="danger" v-if="scope.row.status === 4">有异常</el-tag>
|
<el-tag type="danger" v-if="scope.row.status === 4">有异常</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="wareId" header-align="center" align="center" label="仓库id" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="wareId" header-align="center" align="center" label="仓库id"
|
||||||
<el-table-column prop="amount" header-align="center" align="center" label="总金额" :show-overflow-tooltip="true"></el-table-column>
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="createTime" header-align="center" align="center" label="创建日期" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="amount" header-align="center" align="center" label="总金额"
|
||||||
<el-table-column prop="updateTime" header-align="center" align="center" label="更新日期" :show-overflow-tooltip="true"></el-table-column>
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
|
<el-table-column prop="createTime" header-align="center" align="center" label="创建日期"
|
||||||
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
|
<el-table-column prop="updateTime" header-align="center" align="center" label="更新日期"
|
||||||
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
|
<el-table-column header-align="center" align="center" width="200" label="操作" :show-overflow-tooltip="true">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button type="text" size="small" v-if="scope.row.status===0||scope.row.status===1"
|
||||||
type="text"
|
@click="opendrawer(scope.row)">分配
|
||||||
size="small"
|
|
||||||
v-if="scope.row.status===0||scope.row.status===1"
|
|
||||||
@click="opendrawer(scope.row)"
|
|
||||||
>分配
|
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||||
|
|
@ -85,12 +91,12 @@
|
||||||
></el-pagination>
|
></el-pagination>
|
||||||
<!-- 弹窗, 新增 / 修改 -->
|
<!-- 弹窗, 新增 / 修改 -->
|
||||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||||
<el-dialog title="分配采购人员" :visible.sync="caigoudialogVisible" width="30%">
|
<el-dialog title="分配采购人员" :visible.sync="caigoudialogVisible" width="15%">
|
||||||
<el-select v-model="userId" filterable placeholder="请选择">
|
<el-select v-model="userId" filterable placeholder="请选择" style="width: 60%">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in userList"
|
v-for="item in userList"
|
||||||
:key="item.userId"
|
:key="item.userId"
|
||||||
:label="item.username"
|
:label="item.userName"
|
||||||
:value="item.userId"
|
:value="item.userId"
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
@ -104,7 +110,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AddOrUpdate from "./purchase-add-or-update";
|
import AddOrUpdate from "./purchase-add-or-update";
|
||||||
import {delWarePurchase, getWarePurchaseList} from "@/api/mall/ware/ware-purchase";
|
import {delWarePurchase, editWarePurchase, getWarePurchaseList} from "@/api/mall/ware/ware-purchase";
|
||||||
|
import {listUser} from "@/api/system/user";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Purchase",
|
name: "Purchase",
|
||||||
|
|
@ -138,6 +145,9 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
opendrawer(row) {
|
opendrawer(row) {
|
||||||
|
//下拉框默认值
|
||||||
|
this.userId = row.assigneeName;
|
||||||
|
|
||||||
this.getUserList();
|
this.getUserList();
|
||||||
this.currentRow = row;
|
this.currentRow = row;
|
||||||
this.caigoudialogVisible = true;
|
this.caigoudialogVisible = true;
|
||||||
|
|
@ -151,46 +161,32 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.caigoudialogVisible = false;
|
this.caigoudialogVisible = false;
|
||||||
this.$http({
|
|
||||||
url: this.$http.adornUrl(
|
|
||||||
`/ware/purchase/update`
|
|
||||||
),
|
|
||||||
method: "post",
|
|
||||||
data: this.$http.adornData({
|
|
||||||
id: this.currentRow.id || undefined,
|
|
||||||
assigneeId: user.userId,
|
|
||||||
assigneeName: user.username,
|
|
||||||
phone: user.mobile,
|
|
||||||
status: 1
|
|
||||||
})
|
|
||||||
}).then(({data}) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.$message({
|
|
||||||
message: "操作成功",
|
|
||||||
type: "success",
|
|
||||||
duration: 1500
|
|
||||||
});
|
|
||||||
|
|
||||||
this.userId = "";
|
let data = {
|
||||||
this.getDataList();
|
id: this.currentRow.id,
|
||||||
} else {
|
priority: this.currentRow.priority,
|
||||||
this.$message.error(data.msg);
|
assigneeId: user.userId,
|
||||||
}
|
assigneeName: user.userName,
|
||||||
});
|
phone: user.phonenumber,
|
||||||
|
status: 1
|
||||||
|
}
|
||||||
|
editWarePurchase(data).then(res => {
|
||||||
|
this.$modal.notifySuccess("修改成功")
|
||||||
|
this.userId = "";
|
||||||
|
this.getDataList();
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserList() {
|
getUserList() {
|
||||||
this.$http({
|
let params = {
|
||||||
url: this.$http.adornUrl("/sys/user/list"),
|
pageNum: 1,
|
||||||
method: "get",
|
pageSize: 500,
|
||||||
params: this.$http.adornParams({
|
}
|
||||||
page: 1,
|
listUser(params).then(res => {
|
||||||
limit: 500
|
this.userList = res.rows
|
||||||
})
|
})
|
||||||
}).then(({data}) => {
|
|
||||||
this.userList = data.page.list;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
<el-tag type="danger" v-if="scope.row.status===4">采购失败</el-tag>
|
<el-tag type="danger" v-if="scope.row.status===4">采购失败</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
|
<el-table-column fixed="right" header-align="center" align="center" width="180" label="操作">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
></el-pagination>
|
></el-pagination>
|
||||||
<!-- 弹窗, 新增 / 修改 -->
|
<!-- 弹窗, 新增 / 修改 -->
|
||||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||||
<el-dialog title="合并到整单" :visible.sync="mergedialogVisible">
|
<el-dialog title="合并到整单" width="450px" :visible.sync="mergedialogVisible">
|
||||||
<!-- id assignee_id assignee_name phone priority status -->
|
<!-- id assignee_id assignee_name phone priority status -->
|
||||||
<el-select v-model="purchaseId" placeholder="请选择" clearable filterable>
|
<el-select v-model="purchaseId" placeholder="请选择" clearable filterable>
|
||||||
<el-option
|
<el-option
|
||||||
|
|
@ -90,10 +90,9 @@
|
||||||
:label="item.id"
|
:label="item.id"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
<span style="float: left">{{ item.id }}</span>
|
<span>{{ item.id }}</span>
|
||||||
<span
|
<span v-html="' '"></span>
|
||||||
style="float: right; color: #8492a6; font-size: 13px"
|
<span style=" color: #8492a6; font-size: 13px">采购人员:{{ item.assigneeName }}手机号:{{ item.phone }}</span>
|
||||||
>{{ item.assigneeName }}:{{ item.phone }}</span>
|
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
|
|
@ -108,6 +107,7 @@
|
||||||
import AddOrUpdate from "./purchasedetail-add-or-update";
|
import AddOrUpdate from "./purchasedetail-add-or-update";
|
||||||
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
||||||
import {delWarePurchaseDetail, getWarePurchaseDetailList} from "@/api/mall/ware/ware-purchase-detail";
|
import {delWarePurchaseDetail, getWarePurchaseDetailList} from "@/api/mall/ware/ware-purchase-detail";
|
||||||
|
import {mergePurchase, unreceiveList} from "@/api/mall/ware/ware-purchase";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "PurchaseDetail",
|
name: "PurchaseDetail",
|
||||||
|
|
@ -154,39 +154,24 @@ export default {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$http({
|
mergePurchase({items: items}).then(res => {
|
||||||
url: this.$http.adornUrl("/ware/purchase/merge"),
|
|
||||||
method: "post",
|
|
||||||
data: this.$http.adornData({items: items}, false)
|
|
||||||
}).then(({data}) => {
|
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.$http({
|
mergePurchase({purchaseId: this.purchaseId, items: items}).then(res => {
|
||||||
url: this.$http.adornUrl("/ware/purchase/merge"),
|
|
||||||
method: "post",
|
|
||||||
data: this.$http.adornData(
|
|
||||||
{purchaseId: this.purchaseId, items: items},
|
|
||||||
false
|
|
||||||
)
|
|
||||||
}).then(({data}) => {
|
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
this.mergedialogVisible = false;
|
this.mergedialogVisible = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getUnreceivedPurchase() {
|
getUnreceivedPurchase() {
|
||||||
this.$http({
|
unreceiveList().then(res => {
|
||||||
url: this.$http.adornUrl("/ware/purchase/unreceive/list"),
|
this.purchasetableData = res.page.list;
|
||||||
method: "get",
|
})
|
||||||
params: this.$http.adornParams({})
|
|
||||||
}).then(({data}) => {
|
|
||||||
this.purchasetableData = data.page.list;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleBatchCommand(cmd) {
|
handleBatchCommand(cmd) {
|
||||||
if (cmd === "delete") {
|
if (cmd === "delete") {
|
||||||
this.deleteHandle();
|
this.deleteHandle();
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,11 @@ public class SinaNewsTask {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<SinaNews> collect = sinaNewsList.stream()
|
||||||
|
.filter(sinaNews -> !"彩票".equals(sinaNews.getTitle()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
sinaNewsService.saveBatch(sinaNewsList, 30);
|
sinaNewsService.saveBatch(collect, 30);
|
||||||
|
|
||||||
//删除重复
|
//删除重复
|
||||||
int num = sinaNewsService.deleteRepeatData();
|
int num = sinaNewsService.deleteRepeatData();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||||
import com.xjs.mall.ware.service.PurchaseService;
|
import com.xjs.mall.ware.service.PurchaseService;
|
||||||
|
import com.xjs.mall.ware.vo.MergeVo;
|
||||||
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.AddGroup;
|
||||||
|
|
@ -15,6 +16,7 @@ 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.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -32,6 +34,22 @@ public class PurchaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseService purchaseService;
|
private PurchaseService purchaseService;
|
||||||
|
|
||||||
|
@ApiOperation("合并采购单")
|
||||||
|
@PostMapping("/merge")
|
||||||
|
public R mergePurchase(@RequestBody MergeVo mergeVo) {
|
||||||
|
purchaseService.mergePurchase(mergeVo);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("未领取采购单列表")
|
||||||
|
@GetMapping("/unreceive/list")
|
||||||
|
public R unreceiveList(@RequestParam Map<String, Object> params) {
|
||||||
|
PageUtils page = purchaseService.queryPageUnreceive(params);
|
||||||
|
|
||||||
|
return R.ok().put("page", page);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -62,6 +80,7 @@ public class PurchaseController {
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
@Log(title = "采购单", businessType = BusinessType.INSERT)
|
@Log(title = "采购单", businessType = BusinessType.INSERT)
|
||||||
public R save(@Validated(AddGroup.class) @RequestBody PurchaseEntity purchase) {
|
public R save(@Validated(AddGroup.class) @RequestBody PurchaseEntity purchase) {
|
||||||
|
purchase.setCreateTime(new Date());
|
||||||
purchaseService.save(purchase);
|
purchaseService.save(purchase);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
@ -74,6 +93,7 @@ public class PurchaseController {
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
@Log(title = "采购单", businessType = BusinessType.UPDATE)
|
@Log(title = "采购单", businessType = BusinessType.UPDATE)
|
||||||
public R update(@Validated(UpdateGroup.class) @RequestBody PurchaseEntity purchase) {
|
public R update(@Validated(UpdateGroup.class) @RequestBody PurchaseEntity purchase) {
|
||||||
|
purchase.setUpdateTime(new Date());
|
||||||
purchaseService.updateById(purchase);
|
purchaseService.updateById(purchase);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.xjs.mall.ware.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||||
|
import com.xjs.mall.ware.vo.MergeVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -16,5 +17,18 @@ import java.util.Map;
|
||||||
public interface PurchaseService extends IService<PurchaseEntity> {
|
public interface PurchaseService extends IService<PurchaseEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询未领取的采购单
|
||||||
|
* @param params 分页条件
|
||||||
|
* @return page
|
||||||
|
*/
|
||||||
|
PageUtils queryPageUnreceive(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并采购单
|
||||||
|
* @param mergeVo 合并的参数
|
||||||
|
*/
|
||||||
|
void mergePurchase(MergeVo mergeVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,91 @@
|
||||||
package com.xjs.mall.ware.service.impl;
|
package com.xjs.mall.ware.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
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.xjs.mall.ware.dao.PurchaseDao;
|
import com.xjs.mall.ware.dao.PurchaseDao;
|
||||||
|
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||||
|
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||||
import com.xjs.mall.ware.service.PurchaseService;
|
import com.xjs.mall.ware.service.PurchaseService;
|
||||||
|
import com.xjs.mall.ware.vo.MergeVo;
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.xjs.consts.WareConstant.PurchaseStatusEnum.ASSIGNED;
|
||||||
|
import static com.xjs.consts.WareConstant.PurchaseStatusEnum.CREATED;
|
||||||
|
|
||||||
|
|
||||||
@Service("purchaseService")
|
@Service("purchaseService")
|
||||||
|
@Transactional
|
||||||
public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity> implements PurchaseService {
|
public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity> implements PurchaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PurchaseDetailService purchaseDetailService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<PurchaseEntity> page = this.page(
|
IPage<PurchaseEntity> page = this.page(
|
||||||
new Query<PurchaseEntity>().getPage(params),
|
new Query<PurchaseEntity>().getPage(params),
|
||||||
new QueryWrapper<PurchaseEntity>()
|
new QueryWrapper<>()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public PageUtils queryPageUnreceive(Map<String, Object> params) {
|
||||||
|
LambdaQueryWrapper<PurchaseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(PurchaseEntity::getStatus, 0).or().eq(PurchaseEntity::getStatus, 1);
|
||||||
|
|
||||||
|
IPage<PurchaseEntity> page = this.page(new Query<PurchaseEntity>().getPage(params), wrapper);
|
||||||
|
|
||||||
|
return new PageUtils(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mergePurchase(MergeVo mergeVo) {
|
||||||
|
Long purchaseId = mergeVo.getPurchaseId();
|
||||||
|
//新建采购单
|
||||||
|
if (purchaseId == null) {
|
||||||
|
PurchaseEntity purchaseEntity = new PurchaseEntity();
|
||||||
|
purchaseEntity.setCreateTime(new Date());
|
||||||
|
purchaseEntity.setUpdateTime(new Date());
|
||||||
|
purchaseEntity.setStatus(CREATED.getCode()); //默认采购单状态
|
||||||
|
|
||||||
|
super.save(purchaseEntity);
|
||||||
|
|
||||||
|
purchaseId = purchaseEntity.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
//合并采购单
|
||||||
|
List<Long> items = mergeVo.getItems();
|
||||||
|
Long finalPurchaseId = purchaseId;
|
||||||
|
|
||||||
|
List<PurchaseDetailEntity> collect = items.stream().map(i -> {
|
||||||
|
PurchaseDetailEntity detailEntity = new PurchaseDetailEntity();
|
||||||
|
detailEntity.setId(i);
|
||||||
|
detailEntity.setPurchaseId(finalPurchaseId);
|
||||||
|
detailEntity.setStatus(ASSIGNED.getCode());
|
||||||
|
return detailEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
purchaseDetailService.updateBatchById(collect);
|
||||||
|
|
||||||
|
PurchaseEntity purchaseEntity = new PurchaseEntity();
|
||||||
|
purchaseEntity.setId(purchaseId);
|
||||||
|
purchaseEntity.setUpdateTime(new Date());
|
||||||
|
super.updateById(purchaseEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.xjs.mall.ware.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并采购单vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MergeVo {
|
||||||
|
|
||||||
|
private Long purchaseId; //整单id
|
||||||
|
private List<Long> items;//[1,2,3,4] //合并项集合
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue