1、完成采购单实现 页面todo
This commit is contained in:
parent
b060f46fb2
commit
9b921c3753
|
|
@ -0,0 +1,21 @@
|
|||
package com.xjs.mall;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.xjs.mall.other.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* 远程调用商品服务feign
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-03-24
|
||||
*/
|
||||
@FeignClient(contextId = "remoteProductFeign",
|
||||
value = ServiceNameConstants.MALL_PRODUCT_SERVICE)
|
||||
public interface RemoteProductFeign {
|
||||
|
||||
@GetMapping("/product/skuinfo/getSkuNameByIdForRPC/{skuId}")
|
||||
R getSkuNameById(@PathVariable("skuId") Long skuId);
|
||||
}
|
||||
|
|
@ -47,5 +47,10 @@ public class ServiceNameConstants {
|
|||
*/
|
||||
public static final String MALL_COUPON_SERVICE = "xjs-mall-coupon";
|
||||
|
||||
/**
|
||||
* 商品服务的serviceid
|
||||
*/
|
||||
public static final String MALL_PRODUCT_SERVICE = "xjs-mall-product";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
</el-form-item>
|
||||
|
||||
<el-form-item label="关键字">
|
||||
<el-input style="width:120px;" v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
<el-input style="width:220px;" v-model="dataForm.key" placeholder="请输入采购人、手机号等" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button-group>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
package com.xjs.mall.product.controller;
|
||||
|
||||
import com.xjs.mall.other.R;
|
||||
import com.xjs.mall.product.entity.SkuInfoEntity;
|
||||
import com.xjs.mall.product.service.SkuInfoService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.other.R;
|
||||
import com.xjs.web.MyBaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -20,7 +19,7 @@ import java.util.Map;
|
|||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @since 2022-03-15 10:16:53
|
||||
* @since 2022-03-15 10:16:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("product/skuinfo")
|
||||
|
|
@ -34,11 +33,22 @@ public class SkuInfoController extends MyBaseController<SkuInfoEntity> {
|
|||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("列表")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
super.checkParams(params);
|
||||
PageUtils page = skuInfoService.queryPageByCondition(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("getSkuNameByIdForRPC/{skuId}")
|
||||
@ApiOperation("远程调用-根据skuId查询sku名称")
|
||||
public R getSkuNameById(@PathVariable("skuId") Long skuId) {
|
||||
SkuInfoEntity skuInfoEntity = skuInfoService.getById(skuId);
|
||||
if (Objects.nonNull(skuInfoEntity)) {
|
||||
return R.ok(skuInfoEntity.getSkuName());
|
||||
}
|
||||
return R.error("根据skuId未获取到sku信息");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.xjs.mall.other.R;
|
|||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||
import com.xjs.mall.ware.service.PurchaseService;
|
||||
import com.xjs.mall.ware.vo.MergeVo;
|
||||
import com.xjs.mall.ware.vo.PurchaseDoneVo;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
|
|
@ -35,6 +36,14 @@ public class PurchaseController {
|
|||
@Autowired
|
||||
private PurchaseService purchaseService;
|
||||
|
||||
@ApiOperation("完成采购单")
|
||||
@PostMapping("/done")
|
||||
public R done(@RequestBody PurchaseDoneVo doneVo) {
|
||||
purchaseService.done(doneVo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("领取采购单")
|
||||
@PostMapping("/received")
|
||||
public R received(@RequestBody List<Long> ids) {
|
||||
|
|
@ -44,8 +53,6 @@ public class PurchaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("合并采购单")
|
||||
@PostMapping("/merge")
|
||||
public R mergePurchase(@RequestBody MergeVo mergeVo) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
package com.xjs.mall.ware.dao;
|
||||
|
||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 商品库存
|
||||
*
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 09:56:19
|
||||
*/
|
||||
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {
|
||||
|
||||
/**
|
||||
* 添加库存
|
||||
* @param skuId 商品id
|
||||
* @param wareId 仓库id
|
||||
* @param skuNum 商品数量
|
||||
*/
|
||||
void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.xjs.mall.ware.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||
import com.xjs.mall.ware.vo.MergeVo;
|
||||
import com.xjs.mall.ware.vo.PurchaseDoneVo;
|
||||
import com.xjs.utils.PageUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -13,7 +14,7 @@ import java.util.Map;
|
|||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 09:56:19
|
||||
* @since 2022-03-15 09:56:19
|
||||
*/
|
||||
public interface PurchaseService extends IService<PurchaseEntity> {
|
||||
|
||||
|
|
@ -37,5 +38,11 @@ public interface PurchaseService extends IService<PurchaseEntity> {
|
|||
* @param ids 采购单ids
|
||||
*/
|
||||
void received(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 完成采购单
|
||||
* @param doneVo 采购完成vo
|
||||
*/
|
||||
void done(PurchaseDoneVo doneVo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,13 @@ import java.util.Map;
|
|||
public interface WareSkuService extends IService<WareSkuEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 采购完添加库存
|
||||
* @param skuId 商品id
|
||||
* @param wareId 仓库id
|
||||
* @param skuNum 商品数量
|
||||
*/
|
||||
void addStock(Long skuId, Long wareId, Integer skuNum);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ import com.xjs.mall.ware.entity.WareInfoEntity;
|
|||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||
import com.xjs.mall.ware.service.PurchaseService;
|
||||
import com.xjs.mall.ware.service.WareInfoService;
|
||||
import com.xjs.mall.ware.service.WareSkuService;
|
||||
import com.xjs.mall.ware.vo.MergeVo;
|
||||
import com.xjs.mall.ware.vo.PurchaseDoneVo;
|
||||
import com.xjs.mall.ware.vo.PurchaseItemDoneVo;
|
||||
import com.xjs.mall.ware.vo.PurchaseVo;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
|
|
@ -22,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -38,6 +42,8 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
|||
private PurchaseDetailService purchaseDetailService;
|
||||
@Autowired
|
||||
private WareInfoService wareInfoService;
|
||||
@Autowired
|
||||
private WareSkuService wareSkuService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
|
@ -52,7 +58,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
|||
IPage<PurchaseEntity> page = this.page(new Query<PurchaseEntity>().getPage(params), wrapper);
|
||||
List<Object> collect = page.getRecords().stream().map(purchaseEntity -> {
|
||||
PurchaseVo purchaseVo = new PurchaseVo();
|
||||
BeanUtils.copyProperties(purchaseEntity,purchaseVo);
|
||||
BeanUtils.copyProperties(purchaseEntity, purchaseVo);
|
||||
|
||||
if (purchaseEntity.getWareId() != null) {
|
||||
//获取仓库信息
|
||||
|
|
@ -154,4 +160,45 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done(PurchaseDoneVo doneVo) {
|
||||
//改变采购项的状态
|
||||
boolean flag = true; //标志位 --- 如果有人没采购成功就false
|
||||
List<PurchaseItemDoneVo> items = doneVo.getItems();
|
||||
|
||||
ArrayList<PurchaseDetailEntity> updates = new ArrayList<>();
|
||||
|
||||
for (PurchaseItemDoneVo item : items) {
|
||||
PurchaseDetailEntity purchaseDetailEntity = new PurchaseDetailEntity();
|
||||
|
||||
if (item.getStatus() == HASERROR.getCode()) {
|
||||
flag = false;
|
||||
purchaseDetailEntity.setStatus(item.getStatus());
|
||||
} else {
|
||||
purchaseDetailEntity.setStatus(FINISH.getCode());
|
||||
|
||||
//将成功采购的进行入库
|
||||
PurchaseDetailEntity entity = purchaseDetailService.getById(item.getItemId());
|
||||
wareSkuService.addStock(entity.getSkuId(), entity.getWareId(), entity.getSkuNum());
|
||||
|
||||
}
|
||||
purchaseDetailEntity.setId(item.getItemId());
|
||||
|
||||
updates.add(purchaseDetailEntity);
|
||||
}
|
||||
|
||||
purchaseDetailService.updateBatchById(updates);
|
||||
|
||||
//改变采购单状态
|
||||
Long purchaseId = doneVo.getId();
|
||||
PurchaseEntity purchaseEntity = new PurchaseEntity();
|
||||
purchaseEntity.setId(purchaseId);
|
||||
purchaseEntity.setStatus(flag ? FINISH.getCode() : HASERROR.getCode());
|
||||
purchaseEntity.setUpdateTime(new Date());
|
||||
super.updateById(purchaseEntity);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package com.xjs.mall.ware.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||
import com.xjs.mall.RemoteProductFeign;
|
||||
import com.xjs.mall.other.R;
|
||||
import com.xjs.mall.ware.dao.WareSkuDao;
|
||||
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||
|
|
@ -15,17 +19,22 @@ import com.xjs.utils.PageUtils;
|
|||
import com.xjs.utils.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("wareSkuService")
|
||||
@Transactional
|
||||
public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService {
|
||||
|
||||
@Autowired
|
||||
private WareInfoService wareInfoService;
|
||||
@Resource
|
||||
private RemoteProductFeign remoteProductFeign;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
|
@ -42,7 +51,7 @@ public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> i
|
|||
|
||||
List<Object> collect = page.getRecords().stream().map(wareSkuEntity -> {
|
||||
WareSkuVo wareSkuVo = new WareSkuVo();
|
||||
BeanUtils.copyProperties(wareSkuEntity,wareSkuVo);
|
||||
BeanUtils.copyProperties(wareSkuEntity, wareSkuVo);
|
||||
//获取仓库信息
|
||||
WareInfoEntity wareInfoEntity = wareInfoService.getById(wareSkuVo.getWareId());
|
||||
wareSkuVo.setWareName(wareInfoEntity.getName());
|
||||
|
|
@ -55,4 +64,31 @@ public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> i
|
|||
return pageUtils;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStock(Long skuId, Long wareId, Integer skuNum) {
|
||||
//判断是否有库存记录,有--新增,无--更新
|
||||
List<WareSkuEntity> wareSkuEntities = super.baseMapper.selectList(new LambdaQueryWrapper<WareSkuEntity>()
|
||||
.eq(WareSkuEntity::getSkuId, skuId)
|
||||
.eq(WareSkuEntity::getWareId, wareId));
|
||||
|
||||
if (CollUtil.isEmpty(wareSkuEntities)) {
|
||||
WareSkuEntity wareSkuEntity = new WareSkuEntity();
|
||||
wareSkuEntity.setSkuId(skuId);
|
||||
wareSkuEntity.setStock(skuNum);
|
||||
wareSkuEntity.setWareId(wareId);
|
||||
wareSkuEntity.setStockLocked(0);
|
||||
|
||||
//远程查询sku的名字
|
||||
R r = remoteProductFeign.getSkuNameById(skuId);
|
||||
if (r.getCode() == HttpStatus.SUCCESS) {
|
||||
wareSkuEntity.setSkuName((String) r.get("msg"));
|
||||
}
|
||||
|
||||
super.baseMapper.insert(wareSkuEntity);
|
||||
}else {
|
||||
super.baseMapper.addStock(skuId, wareId, skuNum);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.xjs.mall.ware.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购单完成vo
|
||||
*/
|
||||
@Data
|
||||
public class PurchaseDoneVo {
|
||||
|
||||
@NotNull
|
||||
private Long id;//采购单id
|
||||
|
||||
private List<PurchaseItemDoneVo> items;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.xjs.mall.ware.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 采购单采购项目vo
|
||||
*/
|
||||
@Data
|
||||
public class PurchaseItemDoneVo {
|
||||
//{itemId:1,status:4,reason:""}
|
||||
private Long itemId;
|
||||
private Integer status;
|
||||
private String reason;
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<mapper namespace="com.xjs.mall.ware.dao.WareSkuDao">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.xjs.mall.ware.entity.WareSkuEntity" id="wareSkuMap">
|
||||
<result property="id" column="id"/>
|
||||
<result property="skuId" column="sku_id"/>
|
||||
|
|
@ -13,5 +13,12 @@
|
|||
<result property="stockLocked" column="stock_locked"/>
|
||||
</resultMap>
|
||||
|
||||
<update id="addStock">
|
||||
update wms_ware_sku
|
||||
set stock = stock + #{skuNum}
|
||||
where sku_id = #{skuId}
|
||||
and ware_id = #{wareId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue