|
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.dao.auth.DeptDao;
|
|
|
|
|
import com.glxp.api.dao.auth.InvSubWarehouseDao;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicBussinessTypeDao;
|
|
|
|
@ -16,19 +17,27 @@ import com.glxp.api.dao.basic.BasicCorpDao;
|
|
|
|
|
import com.glxp.api.dao.inout.IoOrderDao;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicCorpEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.inv.*;
|
|
|
|
|
import com.glxp.api.req.inout.FilterOrderRequest;
|
|
|
|
|
import com.glxp.api.req.inout.OrderEditRequest;
|
|
|
|
|
import com.glxp.api.req.inv.FilterInvProductDetailRequest;
|
|
|
|
|
import com.glxp.api.req.inv.FilterInvProductRequest;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderResponse;
|
|
|
|
|
import com.glxp.api.res.inout.OrderNoResult;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.service.inv.*;
|
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
@ -44,6 +53,26 @@ public class IoOrderServiceImpl implements IoOrderService {
|
|
|
|
|
private DeptDao deptDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private InvSubWarehouseDao invSubWarehouseDao;
|
|
|
|
|
@Resource
|
|
|
|
|
IBasicBussinessTypeService basicBussinessTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreinOrderService preinOrderService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreinDetailService preinDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvProductDetailService invProductDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvProductService invProductService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreProductService invPreProductService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreProductDetailService invPreProductDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiCalCountUtil udiCalCountUtil;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeService codeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeTempService codeTempService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<IoOrderEntity> selectAll() {
|
|
|
|
@ -121,6 +150,193 @@ public class IoOrderServiceImpl implements IoOrderService {
|
|
|
|
|
return orderDao.delete(new QueryWrapper<IoOrderEntity>().eq("billNo", billNo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//已验收单据删除、单据编辑删除等(删除对应的库存信息)
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteInvByBillNo(List<String> billNos) {
|
|
|
|
|
|
|
|
|
|
for (String billNo : billNos) {
|
|
|
|
|
IoOrderEntity orderEntity = findByBillNo(billNo);
|
|
|
|
|
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
|
|
|
|
|
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
//判断单据是否是预验收单据,如果是预验收单据,则删除预验收库库存
|
|
|
|
|
if (basicBussinessTypeEntity.isPreIn()) {
|
|
|
|
|
preinOrderService.deleteByOrderId(billNo);
|
|
|
|
|
preinDetailService.deleteByOrderId(billNo);
|
|
|
|
|
} else if (basicBussinessTypeEntity.isAdvanceType()) {
|
|
|
|
|
//是否寄售,删除寄售库存
|
|
|
|
|
List<InvPreProductDetailEntity> invProductDetailEntities = invPreProductDetailService.selectByOrderIdFk(billNo);
|
|
|
|
|
for (InvPreProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
|
//更新库存
|
|
|
|
|
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
|
|
|
|
|
if (invProductEntity != null) {
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setInCount(count);
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setOutCount(count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invPreProductService.update(invProductEntity);
|
|
|
|
|
}
|
|
|
|
|
//删除库存详情
|
|
|
|
|
invPreProductDetailService.deleteByOrderId(billNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//删除普通库存
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailService.selectByOrderIdFk(billNo);
|
|
|
|
|
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
|
//更新库存
|
|
|
|
|
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
|
|
|
|
|
if (invProductEntity != null) {
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setInCount(count);
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setOutCount(count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invProductService.update(invProductEntity);
|
|
|
|
|
}
|
|
|
|
|
//删除库存详情
|
|
|
|
|
invProductDetailService.deleteByOrderId(billNo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailCodeService ioOrderDetailCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailResultService ioOrderDetailResultService;
|
|
|
|
|
|
|
|
|
|
//单据编辑条码减一
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteInvCode(String billNo, String code) {
|
|
|
|
|
|
|
|
|
|
//查询条码
|
|
|
|
|
IoOrderEntity orderEntity = findByBillNo(billNo);
|
|
|
|
|
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED
|
|
|
|
|
|| orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
|
|
|
|
|
//更新正式表
|
|
|
|
|
IoCodeEntity ioCodeEntity = codeService.findByUnique(billNo, code);
|
|
|
|
|
if (ioCodeEntity.getCount() > 1) {
|
|
|
|
|
//更新码表
|
|
|
|
|
ioCodeEntity.setCount(ioCodeEntity.getCount() - 1);
|
|
|
|
|
int reCount = udiCalCountUtil.getActCount(ioCodeEntity.getRelId());
|
|
|
|
|
ioCodeEntity.setReCount(ioCodeEntity.getReCount() - reCount);
|
|
|
|
|
codeService.updateById(ioCodeEntity); //更新码详情
|
|
|
|
|
|
|
|
|
|
//更新扫码单据详情
|
|
|
|
|
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo());
|
|
|
|
|
ioOrderDetailCodeEntity.setReCount(ioOrderDetailCodeEntity.getReCount() - reCount);
|
|
|
|
|
ioOrderDetailCodeService.update(ioOrderDetailCodeEntity);
|
|
|
|
|
|
|
|
|
|
//更新结果详情
|
|
|
|
|
IoOrderDetailResultEntity ioOrderDetailResultEntity = ioOrderDetailResultService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo());
|
|
|
|
|
ioOrderDetailResultEntity.setReCount(ioOrderDetailResultEntity.getReCount() - reCount);
|
|
|
|
|
ioOrderDetailResultService.update(ioOrderDetailResultEntity);
|
|
|
|
|
} else {
|
|
|
|
|
//如果数量扣减之后为0,直接删除此条码
|
|
|
|
|
codeService.deleteById(ioCodeEntity.getId());
|
|
|
|
|
}
|
|
|
|
|
//已审核单据需扣减库存
|
|
|
|
|
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
|
|
|
|
|
|
|
|
|
|
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
|
|
|
|
|
//预验收库存
|
|
|
|
|
if (basicBussinessTypeEntity.isPreIn()) {
|
|
|
|
|
|
|
|
|
|
InvPreinDetailEntity invPreinDetailEntity = preinDetailService.findByCode(billNo, code);
|
|
|
|
|
int count = invPreinDetailEntity.getCount() - 1;
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
preinDetailService.deleteById(invPreinDetailEntity.getId());
|
|
|
|
|
} else {
|
|
|
|
|
invPreinDetailEntity.setCount(count);
|
|
|
|
|
int reCount = udiCalCountUtil.getActCount(invPreinDetailEntity.getRelId());
|
|
|
|
|
invPreinDetailEntity.setReCount(invPreinDetailEntity.getReCount() - reCount);
|
|
|
|
|
preinDetailService.update(invPreinDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (basicBussinessTypeEntity.isAdvanceType()) { //寄售库存
|
|
|
|
|
InvPreProductDetailEntity invProductDetailEntity = invPreProductDetailService.selectByCode(billNo, code);
|
|
|
|
|
int count = invProductDetailEntity.getCount() - 1;
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
invPreProductService.deleteById(invProductDetailEntity.getId());
|
|
|
|
|
} else {
|
|
|
|
|
//更新详情表
|
|
|
|
|
invProductDetailEntity.setCount(count);
|
|
|
|
|
int reCount = udiCalCountUtil.getActCount(invProductDetailEntity.getRelId());
|
|
|
|
|
invProductDetailEntity.setReCount(invProductDetailEntity.getReCount() - reCount);
|
|
|
|
|
invPreProductDetailService.update(invProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
//更新产品表
|
|
|
|
|
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
|
|
|
|
|
if (invProductEntity != null) {
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int inCount = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setInCount(inCount);
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int outCount = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setOutCount(outCount);
|
|
|
|
|
}
|
|
|
|
|
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
|
|
|
|
|
}
|
|
|
|
|
invPreProductService.update(invProductEntity);
|
|
|
|
|
} else { //普通库存
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectByCode(billNo, code);
|
|
|
|
|
int count = invProductDetailEntity.getCount() - 1;
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
invProductDetailService.deleteById(invProductDetailEntity.getId());
|
|
|
|
|
} else {
|
|
|
|
|
//更新详情表
|
|
|
|
|
invProductDetailEntity.setCount(count);
|
|
|
|
|
int reCount = udiCalCountUtil.getActCount(invProductDetailEntity.getRelId());
|
|
|
|
|
invProductDetailEntity.setReCount(invProductDetailEntity.getReCount() - reCount);
|
|
|
|
|
invProductDetailService.update(invProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
//更新产品表
|
|
|
|
|
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
|
|
|
|
|
if (invProductEntity != null) {
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int inCount = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setInCount(inCount);
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
|
|
|
|
|
int outCount = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
|
|
|
|
|
invProductEntity.setOutCount(outCount);
|
|
|
|
|
}
|
|
|
|
|
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
|
|
|
|
|
}
|
|
|
|
|
invProductService.update(invProductEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//更新临时表
|
|
|
|
|
IoCodeTempEntity ioCodeEntity = codeTempService.findByUnique(billNo, code);
|
|
|
|
|
if (ioCodeEntity.getCount() > 1) {
|
|
|
|
|
//删除一个条码
|
|
|
|
|
ioCodeEntity.setCount(ioCodeEntity.getCount() - 1);
|
|
|
|
|
int reCount = udiCalCountUtil.getActCount(ioCodeEntity.getRelId());
|
|
|
|
|
ioCodeEntity.setReCount(ioCodeEntity.getReCount() - reCount);
|
|
|
|
|
codeTempService.updateById(ioCodeEntity); //更新码详情
|
|
|
|
|
} else {
|
|
|
|
|
//如果数量扣减之后为0,直接删除此条码
|
|
|
|
|
codeService.deleteById(ioCodeEntity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<IoOrderResponse> filterList(FilterOrderRequest filterOrderRequest) {
|
|
|
|
|
if (null == filterOrderRequest) {
|
|
|
|
|