|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.dromara.wms.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
@ -9,6 +10,11 @@ import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
import org.dromara.wms.domain.BaseSupplierInfo;
|
|
|
|
|
import org.dromara.wms.domain.WmsInstockOrder;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsInstockOrderVo;
|
|
|
|
|
import org.dromara.wms.mapper.WmsInstockOrderMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsPurchaseOrderBo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsPurchaseOrderVo;
|
|
|
|
@ -16,9 +22,12 @@ import org.dromara.wms.domain.WmsPurchaseOrder;
|
|
|
|
|
import org.dromara.wms.mapper.WmsPurchaseOrderMapper;
|
|
|
|
|
import org.dromara.wms.service.IWmsPurchaseOrderService;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 采购订单Service业务层处理
|
|
|
|
@ -31,6 +40,10 @@ import java.util.Collection;
|
|
|
|
|
public class WmsPurchaseOrderServiceImpl implements IWmsPurchaseOrderService {
|
|
|
|
|
|
|
|
|
|
private final WmsPurchaseOrderMapper baseMapper;
|
|
|
|
|
private static final AtomicInteger sequence = new AtomicInteger(0);
|
|
|
|
|
public static Integer nextSequence() {
|
|
|
|
|
return sequence.incrementAndGet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询采购订单
|
|
|
|
@ -73,6 +86,8 @@ public class WmsPurchaseOrderServiceImpl implements IWmsPurchaseOrderService {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
MPJLambdaWrapper<WmsPurchaseOrder> lqw = JoinWrappers.lambda(WmsPurchaseOrder.class)
|
|
|
|
|
.selectAll(WmsPurchaseOrder.class)
|
|
|
|
|
.select(BaseSupplierInfo::getSupplierCode)
|
|
|
|
|
.leftJoin(BaseSupplierInfo.class,BaseSupplierInfo::getSupplierId,WmsPurchaseOrder::getSupplierId)
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getPoNo()), WmsPurchaseOrder::getPoNo, bo.getPoNo())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getPoStatus()), WmsPurchaseOrder::getPoStatus, bo.getPoStatus())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getPlanDeliveryDate()), WmsPurchaseOrder::getPlanDeliveryDate, bo.getPlanDeliveryDate())
|
|
|
|
@ -96,14 +111,39 @@ public class WmsPurchaseOrderServiceImpl implements IWmsPurchaseOrderService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public WmsPurchaseOrder insertByBo(WmsPurchaseOrderBo bo) {
|
|
|
|
|
String username = LoginHelper.getUsername();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHssmm");
|
|
|
|
|
String orderDate = format.format(date);
|
|
|
|
|
String order = "PUR";
|
|
|
|
|
String orderLast="";
|
|
|
|
|
Integer value = nextSequence();
|
|
|
|
|
if (value.toString().length()==4){
|
|
|
|
|
sequence.set(1);
|
|
|
|
|
orderLast = generateOrder(sequence.get());
|
|
|
|
|
}else {
|
|
|
|
|
orderLast = generateOrder(value);
|
|
|
|
|
}
|
|
|
|
|
String purOrder = order + orderDate + orderLast;
|
|
|
|
|
WmsPurchaseOrder add = MapstructUtils.convert(bo, WmsPurchaseOrder.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
add.setPoNo(purOrder);
|
|
|
|
|
add.setCreateBy(username);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setPoId(add.getPoId());
|
|
|
|
|
}
|
|
|
|
|
return add;
|
|
|
|
|
}
|
|
|
|
|
public String generateOrder(Integer value){
|
|
|
|
|
if (value.toString().length()<3){
|
|
|
|
|
String fixedLengthString = String.format("%03d", value);
|
|
|
|
|
return fixedLengthString;
|
|
|
|
|
}else if (value.toString().length()==3){
|
|
|
|
|
return value.toString();
|
|
|
|
|
}
|
|
|
|
|
return value.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改采购订单
|
|
|
|
@ -114,6 +154,8 @@ public class WmsPurchaseOrderServiceImpl implements IWmsPurchaseOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateByBo(WmsPurchaseOrderBo bo) {
|
|
|
|
|
WmsPurchaseOrder update = MapstructUtils.convert(bo, WmsPurchaseOrder.class);
|
|
|
|
|
String username = LoginHelper.getUsername();
|
|
|
|
|
update.setUpdateBy(username);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
}
|
|
|
|
|