|
|
|
@ -22,10 +22,12 @@ import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderResponse;
|
|
|
|
|
import com.glxp.api.res.inv.BindInvSpaceRequest;
|
|
|
|
|
import com.glxp.api.res.inv.InvPlaceDetailResponse;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPlaceOrderService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPlaceService;
|
|
|
|
|
import com.glxp.api.util.BeanCopyUtils;
|
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -62,7 +64,10 @@ public class InvPlaceServiceImpl implements InvPlaceService {
|
|
|
|
|
private InvPlaceOrderDetailDao invPlaceOrderDetailDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private UdiRelevanceService udiRelevanceService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CustomerService customerService;
|
|
|
|
|
@Resource
|
|
|
|
|
private GennerOrderUtils gennerOrderUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -565,11 +570,90 @@ public class InvPlaceServiceImpl implements InvPlaceService {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String checkOutCount(BindInvSpaceRequest bindInvSpaceRequest) {
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOne(new QueryWrapper<InvWarehouseEntity>().eq("code", bindInvSpaceRequest.getInvCode()));
|
|
|
|
|
if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) {
|
|
|
|
|
QueryWrapper<InvPreInProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
ew.select("count");
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
InvPreInProductDetailEntity invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreInProductDetailEntity.getCount() <= 0) {
|
|
|
|
|
return "该产品没存在该货架上!";
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())) {
|
|
|
|
|
QueryWrapper ew1 = new QueryWrapper();
|
|
|
|
|
ew1.eq("recordId", bindInvSpaceRequest.getOrderId());
|
|
|
|
|
ew1.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = invPlaceOrderDetailDao.selectOne(ew1);
|
|
|
|
|
if (invPlaceOrderDetailEntity == null) {
|
|
|
|
|
invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(0);
|
|
|
|
|
}
|
|
|
|
|
if (invPlaceOrderDetailEntity.getCount() >= invPreInProductDetailEntity.getCount()) {
|
|
|
|
|
return "该产品库存不足!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) {
|
|
|
|
|
QueryWrapper<InvPreProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
ew.select("count");
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
InvPreProductDetailEntity invPreProductDetailEntity = invPreProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreProductDetailEntity.getCount() <= 0) {
|
|
|
|
|
return "该产品没存在该货架上!";
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())) {
|
|
|
|
|
QueryWrapper ew1 = new QueryWrapper();
|
|
|
|
|
ew1.eq("recordId", bindInvSpaceRequest.getOrderId());
|
|
|
|
|
ew1.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = invPlaceOrderDetailDao.selectOne(ew1);
|
|
|
|
|
if (invPlaceOrderDetailEntity == null) {
|
|
|
|
|
invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(0);
|
|
|
|
|
}
|
|
|
|
|
if (invPlaceOrderDetailEntity.getCount() >= invPreProductDetailEntity.getCount()) {
|
|
|
|
|
return "该产品库存不足!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_NORMAL) {
|
|
|
|
|
QueryWrapper<InvProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
ew.select("count");
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = invProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invProductDetailEntity.getCount() <= 0) {
|
|
|
|
|
return "该产品没存在该货架上!";
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())) {
|
|
|
|
|
QueryWrapper ew1 = new QueryWrapper();
|
|
|
|
|
ew1.eq("recordId", bindInvSpaceRequest.getOrderId());
|
|
|
|
|
ew1.eq("code", bindInvSpaceRequest.getCode());
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = invPlaceOrderDetailDao.selectOne(ew1);
|
|
|
|
|
if (invPlaceOrderDetailEntity == null) {
|
|
|
|
|
invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(0);
|
|
|
|
|
}
|
|
|
|
|
if (invPlaceOrderDetailEntity.getCount() >= invProductDetailEntity.getCount()) {
|
|
|
|
|
return "该产品库存不足!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getActCount(String nameCode) {
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(nameCode);
|
|
|
|
|
int count = getActCount(udiRelevanceResponse);
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getActCount(UdiRelevanceResponse udiRelevanceResponse) {
|
|
|
|
|
int actCount;
|
|
|
|
|
if (!udiRelevanceResponse.getUseDy() && (udiRelevanceResponse.getDiType() == null || udiRelevanceResponse.getDiType() != 2)) {
|
|
|
|
@ -590,4 +674,352 @@ public class InvPlaceServiceImpl implements InvPlaceService {
|
|
|
|
|
|
|
|
|
|
return actCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse unbindInvOrderSpace(BindInvSpaceRequest bindInvSpaceRequest) {
|
|
|
|
|
//查询仓库的部门ID
|
|
|
|
|
// String deptCode = invWarehouseDao.selectParentIdByCode(bindInvSpaceRequest.getInvCode());
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseDao.filterGroupInvSubAndcode(bindInvSpaceRequest.getInvCode());
|
|
|
|
|
List<InvPlaceOrderDetailEntity> invPlaceOrderDetailEntityList = new ArrayList<>();
|
|
|
|
|
int total=0;
|
|
|
|
|
if (bindInvSpaceRequest.getOutCount() > 0) {
|
|
|
|
|
if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) {
|
|
|
|
|
invPlaceOrderDetailEntityList = invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId", bindInvSpaceRequest.getOrderId()));
|
|
|
|
|
for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) {
|
|
|
|
|
|
|
|
|
|
for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) {
|
|
|
|
|
//去掉库存
|
|
|
|
|
QueryWrapper<InvPreInProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
InvPreInProductDetailEntity invPreInProductDetailEntity = new InvPreInProductDetailEntity();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.gt("inCount", 0);
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invPreInProductDetailEntity.getInCount() > 0) {
|
|
|
|
|
String nameCode = invPreInProductDetailEntity.getNameCode();
|
|
|
|
|
int reCount = getActCount(nameCode);
|
|
|
|
|
invPreInProductDetailEntity.setInCount(invPreInProductDetailEntity.getInCount() - 1);
|
|
|
|
|
invPreInProductDetailEntity.setCount(invPreInProductDetailEntity.getCount() - 1);
|
|
|
|
|
invPreInProductDetailEntity.setReCount(invPreInProductDetailEntity.getReCount() - reCount);
|
|
|
|
|
invPreInProductDetailDao.updateById(invPreInProductDetailEntity);
|
|
|
|
|
|
|
|
|
|
//如果库存为空就删了该数据
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreInProductDetailEntity != null && invPreInProductDetailEntity.getInCount() == 0 && invPreInProductDetailEntity.getOutCount() == 0
|
|
|
|
|
&& invPreInProductDetailEntity.getCount() == 0 && invPreInProductDetailEntity.getReCount() == 0) {
|
|
|
|
|
invPreInProductDetailDao.deleteById(invPreInProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果有存在数据就加没有就新建
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.and(o -> o.isNull("invSpaceCode").or().eq("invSpaceCode", ""));
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreInProductDetailEntity != null) {
|
|
|
|
|
nameCode = invPreInProductDetailEntity.getNameCode();
|
|
|
|
|
reCount = getActCount(nameCode);
|
|
|
|
|
invPreInProductDetailEntity.setInCount(invPreInProductDetailEntity.getInCount() + 1);
|
|
|
|
|
invPreInProductDetailEntity.setCount(invPreInProductDetailEntity.getCount() + 1);
|
|
|
|
|
invPreInProductDetailEntity.setReCount(invPreInProductDetailEntity.getReCount() + reCount);
|
|
|
|
|
invPreInProductDetailDao.updateById(invPreInProductDetailEntity);
|
|
|
|
|
} else {
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew);
|
|
|
|
|
invPreInProductDetailEntity.setId(null);
|
|
|
|
|
invPreInProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
invPreInProductDetailEntity.setInCount(1);
|
|
|
|
|
invPreInProductDetailEntity.setCount(1);
|
|
|
|
|
invPreInProductDetailEntity.setReCount(reCount);
|
|
|
|
|
invPreInProductDetailEntity.setOutCount(0);
|
|
|
|
|
invPreInProductDetailDao.insert(invPreInProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) {
|
|
|
|
|
|
|
|
|
|
invPlaceOrderDetailEntityList = invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId", bindInvSpaceRequest.getOrderId()));
|
|
|
|
|
for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) {
|
|
|
|
|
|
|
|
|
|
for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) {
|
|
|
|
|
//去掉库存
|
|
|
|
|
QueryWrapper<InvPreProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
InvPreProductDetailEntity invPreProductDetailEntity = new InvPreProductDetailEntity();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.gt("inCount", 0);
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreProductDetailEntity = invPreProductDetailDao.selectOne(ew);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invPreProductDetailEntity.getInCount() > 0) {
|
|
|
|
|
String nameCode = invPlaceOrderDetailEntity.getNameCode();
|
|
|
|
|
int reCount = getActCount(nameCode);
|
|
|
|
|
invPreProductDetailEntity.setInCount(invPreProductDetailEntity.getInCount() - 1);
|
|
|
|
|
invPreProductDetailEntity.setCount(invPreProductDetailEntity.getCount() - 1);
|
|
|
|
|
invPreProductDetailEntity.setReCount(invPreProductDetailEntity.getReCount() - reCount);
|
|
|
|
|
invPreProductDetailDao.updateById(invPreProductDetailEntity);
|
|
|
|
|
|
|
|
|
|
//如果库存为空就删了该数据
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreProductDetailEntity = invPreProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreProductDetailEntity != null && invPreProductDetailEntity.getInCount() == 0 && invPreProductDetailEntity.getOutCount() == 0
|
|
|
|
|
&& invPreProductDetailEntity.getCount() == 0 && invPreProductDetailEntity.getReCount() == 0) {
|
|
|
|
|
invPreProductDetailDao.deleteById(invPreProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果有存在数据就加没有就新建
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.and(o -> o.isNull("invSpaceCode").or().eq("invSpaceCode", ""));
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreProductDetailEntity = invPreProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invPreProductDetailEntity != null) {
|
|
|
|
|
nameCode = invPreProductDetailEntity.getNameCode();
|
|
|
|
|
reCount = getActCount(nameCode);
|
|
|
|
|
invPreProductDetailEntity.setInCount(invPreProductDetailEntity.getInCount() + 1);
|
|
|
|
|
invPreProductDetailEntity.setCount(invPreProductDetailEntity.getCount() + 1);
|
|
|
|
|
invPreProductDetailEntity.setReCount(invPreProductDetailEntity.getReCount() + reCount);
|
|
|
|
|
invPreProductDetailDao.updateById(invPreProductDetailEntity);
|
|
|
|
|
} else {
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invPreProductDetailEntity = invPreProductDetailDao.selectOne(ew);
|
|
|
|
|
invPreProductDetailEntity.setId(null);
|
|
|
|
|
invPreProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
invPreProductDetailEntity.setInCount(1);
|
|
|
|
|
invPreProductDetailEntity.setCount(1);
|
|
|
|
|
invPreProductDetailEntity.setReCount(reCount);
|
|
|
|
|
invPreProductDetailEntity.setOutCount(0);
|
|
|
|
|
invPreProductDetailDao.insert(invPreProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
invPlaceOrderDetailEntityList = invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId", bindInvSpaceRequest.getOrderId()));
|
|
|
|
|
for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) {
|
|
|
|
|
|
|
|
|
|
for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) {
|
|
|
|
|
//去掉库存
|
|
|
|
|
QueryWrapper<InvProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.gt("inCount", 0);
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invProductDetailEntity = invProductDetailDao.selectOne(ew);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invProductDetailEntity.getInCount() > 0) {
|
|
|
|
|
String nameCode = invProductDetailEntity.getNameCode();
|
|
|
|
|
int reCount = getActCount(nameCode);
|
|
|
|
|
invProductDetailEntity.setInCount(invProductDetailEntity.getInCount() - 1);
|
|
|
|
|
invProductDetailEntity.setCount(invProductDetailEntity.getCount() - 1);
|
|
|
|
|
invProductDetailEntity.setReCount(invProductDetailEntity.getReCount() - reCount);
|
|
|
|
|
invProductDetailDao.updateById(invProductDetailEntity);
|
|
|
|
|
|
|
|
|
|
//如果库存为空就删了该数据
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invProductDetailEntity = invProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invProductDetailEntity != null && invProductDetailEntity.getInCount() == 0 && invProductDetailEntity.getOutCount() == 0
|
|
|
|
|
&& invProductDetailEntity.getCount() == 0 && invProductDetailEntity.getReCount() == 0) {
|
|
|
|
|
invProductDetailDao.deleteById(invProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果有存在数据就加没有就新建
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.and(o -> o.isNull("invSpaceCode").or().eq("invSpaceCode", ""));
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invProductDetailEntity = invProductDetailDao.selectOne(ew);
|
|
|
|
|
if (invProductDetailEntity != null) {
|
|
|
|
|
nameCode = invProductDetailEntity.getNameCode();
|
|
|
|
|
reCount = getActCount(nameCode);
|
|
|
|
|
invProductDetailEntity.setInCount(invProductDetailEntity.getInCount() + 1);
|
|
|
|
|
invProductDetailEntity.setCount(invProductDetailEntity.getCount() + 1);
|
|
|
|
|
invProductDetailEntity.setReCount(invProductDetailEntity.getReCount() + reCount);
|
|
|
|
|
invProductDetailDao.updateById(invProductDetailEntity);
|
|
|
|
|
} else {
|
|
|
|
|
ew.clear();
|
|
|
|
|
ew.eq("code", invPlaceOrderDetailEntity.getCode());
|
|
|
|
|
ew.last("limit 1");
|
|
|
|
|
invProductDetailEntity = invProductDetailDao.selectOne(ew);
|
|
|
|
|
invProductDetailEntity.setId(null);
|
|
|
|
|
invProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
invProductDetailEntity.setInCount(1);
|
|
|
|
|
invProductDetailEntity.setCount(1);
|
|
|
|
|
invProductDetailEntity.setReCount(reCount);
|
|
|
|
|
invProductDetailEntity.setOutCount(0);
|
|
|
|
|
invProductDetailDao.insert(invProductDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
total = invPlaceOrderDetailEntityList.stream().mapToInt(InvPlaceOrderDetailEntity::getCount).sum();
|
|
|
|
|
} else {
|
|
|
|
|
if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) {
|
|
|
|
|
|
|
|
|
|
QueryWrapper<InvPreInProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
InvPreInProductDetailEntity invPreInProductDetailEntity = new InvPreInProductDetailEntity();
|
|
|
|
|
invPreInProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
List<InvPreInProductDetailEntity> invProductDetailEntityList=invPreInProductDetailDao.selectList(ew);
|
|
|
|
|
//操作人ID
|
|
|
|
|
String userId = customerService.getUserIdStr();
|
|
|
|
|
String recordId = gennerOrderUtils.createInvPlaceOrderNo(new OrderNoTypeBean(Constant.INV_PLACE_ORDER, "yyyyMMdd"));
|
|
|
|
|
//插入主表
|
|
|
|
|
InvPlaceOrderEntity orderEntity = new InvPlaceOrderEntity();
|
|
|
|
|
orderEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
orderEntity.setRecordId(recordId);
|
|
|
|
|
orderEntity.setType(4);
|
|
|
|
|
orderEntity.setCreateUser(userId);
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
invPlaceOrderDao.insert(orderEntity);
|
|
|
|
|
for (InvPreInProductDetailEntity productDetailEntity : invProductDetailEntityList) {
|
|
|
|
|
for (int i=0;i<productDetailEntity.getCount();i++){
|
|
|
|
|
//插入附表
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
invPlaceOrderDetailEntity.setRecordId(recordId);
|
|
|
|
|
invPlaceOrderDetailEntity.setBatchNo(productDetailEntity.getBatchNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setRelId(productDetailEntity.getRelId() + "");
|
|
|
|
|
invPlaceOrderDetailEntity.setNameCode(productDetailEntity.getNameCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setExpireDate(productDetailEntity.getExpireDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setProduceDate(productDetailEntity.getProduceDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setSupId(productDetailEntity.getSupId());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvCode(bindInvSpaceRequest.getInvCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setCode(bindInvSpaceRequest.getCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setSerialNo(productDetailEntity.getSerialNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(1);
|
|
|
|
|
invPlaceOrderDetailDao.insert(invPlaceOrderDetailEntity);
|
|
|
|
|
total++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invPreInProductDetailDao.update(invPreInProductDetailEntity, ew);
|
|
|
|
|
bindInvSpaceRequest.setOrderId(recordId);
|
|
|
|
|
} else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<InvPreProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
InvPreProductDetailEntity invPreProductDetailEntity = new InvPreProductDetailEntity();
|
|
|
|
|
invPreProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
List<InvPreProductDetailEntity> invProductDetailEntityList=invPreProductDetailDao.selectList(ew);
|
|
|
|
|
//操作人ID
|
|
|
|
|
String userId = customerService.getUserIdStr();
|
|
|
|
|
String recordId = gennerOrderUtils.createInvPlaceOrderNo(new OrderNoTypeBean(Constant.INV_PLACE_ORDER, "yyyyMMdd"));
|
|
|
|
|
//插入主表
|
|
|
|
|
InvPlaceOrderEntity orderEntity = new InvPlaceOrderEntity();
|
|
|
|
|
orderEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
orderEntity.setRecordId(recordId);
|
|
|
|
|
orderEntity.setType(4);
|
|
|
|
|
orderEntity.setCreateUser(userId);
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
invPlaceOrderDao.insert(orderEntity);
|
|
|
|
|
for (InvPreProductDetailEntity productDetailEntity : invProductDetailEntityList) {
|
|
|
|
|
for (int i=0;i<productDetailEntity.getCount();i++){
|
|
|
|
|
//插入附表
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
invPlaceOrderDetailEntity.setRecordId(recordId);
|
|
|
|
|
invPlaceOrderDetailEntity.setBatchNo(productDetailEntity.getBatchNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setRelId(productDetailEntity.getRelId() + "");
|
|
|
|
|
invPlaceOrderDetailEntity.setNameCode(productDetailEntity.getNameCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setExpireDate(productDetailEntity.getExpireDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setProduceDate(productDetailEntity.getProduceDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setSupId(productDetailEntity.getSupId());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvCode(bindInvSpaceRequest.getInvCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setCode(bindInvSpaceRequest.getCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setSerialNo(productDetailEntity.getSerialNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(1);
|
|
|
|
|
invPlaceOrderDetailDao.insert(invPlaceOrderDetailEntity);
|
|
|
|
|
total++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invPreProductDetailDao.update(invPreProductDetailEntity, ew);
|
|
|
|
|
bindInvSpaceRequest.setOrderId(recordId);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
QueryWrapper<InvProductDetailEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("invSpaceCode", bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity();
|
|
|
|
|
invProductDetailEntity.setInvSpaceCode("");
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntityList=invProductDetailDao.selectList(ew);
|
|
|
|
|
//操作人ID
|
|
|
|
|
String userId = customerService.getUserIdStr();
|
|
|
|
|
String recordId = gennerOrderUtils.createInvPlaceOrderNo(new OrderNoTypeBean(Constant.INV_PLACE_ORDER, "yyyyMMdd"));
|
|
|
|
|
//插入主表
|
|
|
|
|
InvPlaceOrderEntity orderEntity = new InvPlaceOrderEntity();
|
|
|
|
|
orderEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
orderEntity.setRecordId(recordId);
|
|
|
|
|
orderEntity.setType(4);
|
|
|
|
|
orderEntity.setCreateUser(userId);
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
invPlaceOrderDao.insert(orderEntity);
|
|
|
|
|
for (InvProductDetailEntity productDetailEntity : invProductDetailEntityList) {
|
|
|
|
|
for (int i=0;i<productDetailEntity.getCount();i++){
|
|
|
|
|
//插入附表
|
|
|
|
|
InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity();
|
|
|
|
|
invPlaceOrderDetailEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
invPlaceOrderDetailEntity.setRecordId(recordId);
|
|
|
|
|
invPlaceOrderDetailEntity.setBatchNo(productDetailEntity.getBatchNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setRelId(productDetailEntity.getRelId() + "");
|
|
|
|
|
invPlaceOrderDetailEntity.setNameCode(productDetailEntity.getNameCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setExpireDate(productDetailEntity.getExpireDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setProduceDate(productDetailEntity.getProduceDate());
|
|
|
|
|
invPlaceOrderDetailEntity.setSupId(productDetailEntity.getSupId());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvCode(bindInvSpaceRequest.getInvCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setCode(bindInvSpaceRequest.getCode());
|
|
|
|
|
invPlaceOrderDetailEntity.setSerialNo(productDetailEntity.getSerialNo());
|
|
|
|
|
invPlaceOrderDetailEntity.setCount(1);
|
|
|
|
|
invPlaceOrderDetailDao.insert(invPlaceOrderDetailEntity);
|
|
|
|
|
total++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invProductDetailDao.update(invProductDetailEntity, ew);
|
|
|
|
|
bindInvSpaceRequest.setOrderId(recordId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<InvPlaceOrderEntity> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("recordId", bindInvSpaceRequest.getOrderId());
|
|
|
|
|
InvPlaceOrderEntity invPlaceOrderEntity = new InvPlaceOrderEntity();
|
|
|
|
|
invPlaceOrderEntity.setRecordId(bindInvSpaceRequest.getOrderId());
|
|
|
|
|
invPlaceOrderEntity.setCount(total);
|
|
|
|
|
invPlaceOrderDao.update(invPlaceOrderEntity, ew);
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|