parent
ddc6927910
commit
b060f46fb2
|
|
@ -62,7 +62,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 prop="wareId" header-align="center" align="center" label="仓库id"
|
<el-table-column prop="wareName" header-align="center" align="center" label="仓库名称"
|
||||||
:show-overflow-tooltip="true"></el-table-column>
|
:show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="amount" header-align="center" align="center" label="总金额"
|
<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>
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ package com.xjs.mall.ware.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
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.other.R;
|
||||||
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.mall.ware.vo.MergeVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.mall.other.R;
|
|
||||||
import com.xjs.validation.group.AddGroup;
|
import com.xjs.validation.group.AddGroup;
|
||||||
import com.xjs.validation.group.UpdateGroup;
|
import com.xjs.validation.group.UpdateGroup;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,6 +35,17 @@ public class PurchaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseService purchaseService;
|
private PurchaseService purchaseService;
|
||||||
|
|
||||||
|
@ApiOperation("领取采购单")
|
||||||
|
@PostMapping("/received")
|
||||||
|
public R received(@RequestBody List<Long> ids) {
|
||||||
|
|
||||||
|
purchaseService.received(ids);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("合并采购单")
|
@ApiOperation("合并采购单")
|
||||||
@PostMapping("/merge")
|
@PostMapping("/merge")
|
||||||
public R mergePurchase(@RequestBody MergeVo mergeVo) {
|
public R mergePurchase(@RequestBody MergeVo mergeVo) {
|
||||||
|
|
|
||||||
|
|
@ -30,16 +30,17 @@ public class PurchaseEntity implements Serializable {
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*用户id
|
||||||
*/
|
*/
|
||||||
private Long assigneeId;
|
private Long assigneeId;
|
||||||
/**
|
/**
|
||||||
*
|
*用户名
|
||||||
*/
|
*/
|
||||||
private String assigneeName;
|
private String assigneeName;
|
||||||
/**
|
/**
|
||||||
*
|
*手机号
|
||||||
*/
|
*/
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
|
|
@ -51,15 +52,15 @@ public class PurchaseEntity implements Serializable {
|
||||||
@Max(value = 9999,message = "优先级最大为9999",groups = {AddGroup.class, UpdateGroup.class})
|
@Max(value = 9999,message = "优先级最大为9999",groups = {AddGroup.class, UpdateGroup.class})
|
||||||
private Integer priority;
|
private Integer priority;
|
||||||
/**
|
/**
|
||||||
*
|
*采购单状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
/**
|
||||||
*
|
*仓库id
|
||||||
*/
|
*/
|
||||||
private Long wareId;
|
private Long wareId;
|
||||||
/**
|
/**
|
||||||
*
|
*总金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -16,5 +17,12 @@ import java.util.Map;
|
||||||
public interface PurchaseDetailService extends IService<PurchaseDetailEntity> {
|
public interface PurchaseDetailService extends IService<PurchaseDetailEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按采购 ID 列出详细信息
|
||||||
|
* @param id 采购id
|
||||||
|
* @return 采购list
|
||||||
|
*/
|
||||||
|
List<PurchaseDetailEntity> listDetailByPurchaseId(Long id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||||
import com.xjs.mall.ware.vo.MergeVo;
|
import com.xjs.mall.ware.vo.MergeVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,5 +31,11 @@ public interface PurchaseService extends IService<PurchaseEntity> {
|
||||||
* @param mergeVo 合并的参数
|
* @param mergeVo 合并的参数
|
||||||
*/
|
*/
|
||||||
void mergePurchase(MergeVo mergeVo);
|
void mergePurchase(MergeVo mergeVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领取采购单
|
||||||
|
* @param ids 采购单ids
|
||||||
|
*/
|
||||||
|
void received(List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,10 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailDao, Pu
|
||||||
return pageUtils;
|
return pageUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PurchaseDetailEntity> listDetailByPurchaseId(Long id) {
|
||||||
|
|
||||||
|
return super.list(new LambdaQueryWrapper<PurchaseDetailEntity>().eq(PurchaseDetailEntity::getPurchaseId, id));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,23 @@
|
||||||
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.LambdaQueryWrapper;
|
||||||
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.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.xjs.consts.WareConstant;
|
||||||
|
import com.xjs.exception.MallException;
|
||||||
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.PurchaseDetailEntity;
|
||||||
import com.xjs.mall.ware.entity.PurchaseEntity;
|
import com.xjs.mall.ware.entity.PurchaseEntity;
|
||||||
|
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
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.service.WareInfoService;
|
||||||
import com.xjs.mall.ware.vo.MergeVo;
|
import com.xjs.mall.ware.vo.MergeVo;
|
||||||
|
import com.xjs.mall.ware.vo.PurchaseVo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.utils.Query;
|
import com.xjs.utils.Query;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -21,8 +27,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.xjs.consts.WareConstant.PurchaseStatusEnum.ASSIGNED;
|
import static com.xjs.consts.WareConstant.PurchaseStatusEnum.*;
|
||||||
import static com.xjs.consts.WareConstant.PurchaseStatusEnum.CREATED;
|
|
||||||
|
|
||||||
|
|
||||||
@Service("purchaseService")
|
@Service("purchaseService")
|
||||||
|
|
@ -31,14 +36,35 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseDetailService purchaseDetailService;
|
private PurchaseDetailService purchaseDetailService;
|
||||||
|
@Autowired
|
||||||
|
private WareInfoService wareInfoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<PurchaseEntity> page = this.page(
|
LambdaQueryWrapper<PurchaseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
new Query<PurchaseEntity>().getPage(params),
|
|
||||||
new QueryWrapper<>()
|
|
||||||
);
|
|
||||||
|
|
||||||
|
String key = (String) params.get(Query.KEY_NAME);
|
||||||
|
wrapper.and(StringUtils.isNotEmpty(key), wr -> {
|
||||||
|
wr.like(PurchaseEntity::getAssigneeName, key).or()
|
||||||
|
.eq(PurchaseEntity::getPhone, key);
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (purchaseEntity.getWareId() != null) {
|
||||||
|
//获取仓库信息
|
||||||
|
WareInfoEntity wareInfoEntity = wareInfoService.getById(purchaseVo.getWareId());
|
||||||
|
purchaseVo.setWareName(wareInfoEntity.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return purchaseVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
PageUtils pageUtils = new PageUtils(page);
|
||||||
|
pageUtils.setList(collect);
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +86,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
||||||
PurchaseEntity purchaseEntity = new PurchaseEntity();
|
PurchaseEntity purchaseEntity = new PurchaseEntity();
|
||||||
purchaseEntity.setCreateTime(new Date());
|
purchaseEntity.setCreateTime(new Date());
|
||||||
purchaseEntity.setUpdateTime(new Date());
|
purchaseEntity.setUpdateTime(new Date());
|
||||||
|
purchaseEntity.setPriority(1); //设置优先级默认1
|
||||||
purchaseEntity.setStatus(CREATED.getCode()); //默认采购单状态
|
purchaseEntity.setStatus(CREATED.getCode()); //默认采购单状态
|
||||||
|
|
||||||
super.save(purchaseEntity);
|
super.save(purchaseEntity);
|
||||||
|
|
@ -67,8 +94,17 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
||||||
purchaseId = purchaseEntity.getId();
|
purchaseId = purchaseEntity.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
//合并采购单
|
// 确认采购单状态是 0 或 1 才可以合并
|
||||||
List<Long> items = mergeVo.getItems();
|
List<Long> items = mergeVo.getItems();
|
||||||
|
|
||||||
|
for (Long item : items) {
|
||||||
|
PurchaseDetailEntity entity = purchaseDetailService.getById(item);
|
||||||
|
if (!(entity.getStatus() == CREATED.getCode() || entity.getStatus() == ASSIGNED.getCode())) {
|
||||||
|
throw new MallException("采购单只有在新建或分配状态才能合并");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//合并采购单
|
||||||
Long finalPurchaseId = purchaseId;
|
Long finalPurchaseId = purchaseId;
|
||||||
|
|
||||||
List<PurchaseDetailEntity> collect = items.stream().map(i -> {
|
List<PurchaseDetailEntity> collect = items.stream().map(i -> {
|
||||||
|
|
@ -88,4 +124,34 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(List<Long> ids) {
|
||||||
|
//确认当前采购单是新建或者已分配状态
|
||||||
|
List<PurchaseEntity> collect = ids.stream().map(super::getById)
|
||||||
|
.filter(item ->
|
||||||
|
item.getStatus() == CREATED.getCode() || item.getStatus() == ASSIGNED.getCode()
|
||||||
|
)
|
||||||
|
.peek(item -> {
|
||||||
|
item.setStatus(RECEIVE.getCode());
|
||||||
|
item.setUpdateTime(new Date());
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
//改变采购单的状态
|
||||||
|
super.updateBatchById(collect);
|
||||||
|
|
||||||
|
//改变采购项的状态
|
||||||
|
collect.forEach(item -> {
|
||||||
|
List<PurchaseDetailEntity> entities = purchaseDetailService.listDetailByPurchaseId(item.getId());
|
||||||
|
List<PurchaseDetailEntity> PurchaseDetailEntityList = entities.stream().map(entity -> {
|
||||||
|
PurchaseDetailEntity purchaseDetailEntity = new PurchaseDetailEntity();
|
||||||
|
purchaseDetailEntity.setId(entity.getId());
|
||||||
|
purchaseDetailEntity.setStatus(WareConstant.PurchaseDetailStatusEnum.BUYING.getCode());
|
||||||
|
return purchaseDetailEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
purchaseDetailService.updateBatchById(PurchaseDetailEntityList);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.xjs.mall.ware.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购信息vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PurchaseVo {
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*用户id
|
||||||
|
*/
|
||||||
|
private Long assigneeId;
|
||||||
|
/**
|
||||||
|
*用户名
|
||||||
|
*/
|
||||||
|
private String assigneeName;
|
||||||
|
/**
|
||||||
|
*手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优先级
|
||||||
|
*/
|
||||||
|
private Integer priority;
|
||||||
|
/**
|
||||||
|
*采购单状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
*仓库id
|
||||||
|
*/
|
||||||
|
private Long wareId;
|
||||||
|
/**
|
||||||
|
*总金额
|
||||||
|
*/
|
||||||
|
private BigDecimal amount;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库名称
|
||||||
|
*/
|
||||||
|
private String wareName;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue