|
|
|
@ -8,6 +8,7 @@ import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.entity.auth.InvWarehouseEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
@ -16,6 +17,7 @@ import com.glxp.api.entity.inv.InvPreinDetailEntity;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderCheckResultResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
|
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPreinDetailService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPreinOrderService;
|
|
|
|
@ -728,6 +730,7 @@ public class IoCheckInoutService {
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setAuditTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
List<IoCodeEntity> codeEntities = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
genInv(orderEntity, bussinessTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -743,76 +746,75 @@ public class IoCheckInoutService {
|
|
|
|
|
public void genInv(IoOrderEntity orderEntity, BasicBussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
|
|
|
|
|
if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT) && bussinessTypeEntity.isScanPreIn()) {
|
|
|
|
|
ThreadUtil.execAsync(() -> {
|
|
|
|
|
if (StrUtil.isNotEmpty(bussinessTypeEntity.getPreInBackAction())) {
|
|
|
|
|
if (bussinessTypeEntity.getBackPreinType() == 1) { //按单退货
|
|
|
|
|
|
|
|
|
|
String orderIds = bussinessTypeEntity.getCheckPreInOrders();
|
|
|
|
|
if (StrUtil.isNotEmpty(orderIds)) {
|
|
|
|
|
String[] orderIdArray = StringUtils.split(",");
|
|
|
|
|
List<String> orderList = CollUtil.toList(orderIdArray);
|
|
|
|
|
List<IoCodeEntity> outCodeEntitys = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
List<IoCodeEntity> preInCodeEntities = codeService.findByOrderIds(orderList, null);
|
|
|
|
|
|
|
|
|
|
// 扣减数量
|
|
|
|
|
for (IoCodeEntity preInCodeEntity : preInCodeEntities) {
|
|
|
|
|
for (IoCodeEntity codeEntity : outCodeEntitys) {
|
|
|
|
|
if (preInCodeEntity.getCode().equals(codeEntity.getCode())) {
|
|
|
|
|
int count = preInCodeEntity.getMyCount() - codeEntity.getMyCount();
|
|
|
|
|
int reCount = preInCodeEntity.getMyReCount() - codeEntity.getMyReCount();
|
|
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
preInCodeEntity.setCount(count);
|
|
|
|
|
preInCodeEntity.setReCount(reCount);
|
|
|
|
|
codeEntity.setCount(0);
|
|
|
|
|
codeEntity.setReCount(0);
|
|
|
|
|
} else if (count < 0) {
|
|
|
|
|
preInCodeEntity.setCount(0);
|
|
|
|
|
preInCodeEntity.setReCount(0);
|
|
|
|
|
codeEntity.setCount(-count);
|
|
|
|
|
codeEntity.setReCount(-reCount);
|
|
|
|
|
} else {
|
|
|
|
|
preInCodeEntity.setCount(0);
|
|
|
|
|
preInCodeEntity.setReCount(0);
|
|
|
|
|
codeEntity.setCount(0);
|
|
|
|
|
codeEntity.setReCount(0);
|
|
|
|
|
}
|
|
|
|
|
// ThreadUtil.execAsync(() -> {
|
|
|
|
|
if (StrUtil.isNotEmpty(bussinessTypeEntity.getPreInBackAction())) {
|
|
|
|
|
if (bussinessTypeEntity.getBackPreinType() == 1) { //按单退货
|
|
|
|
|
|
|
|
|
|
String orderIds = orderEntity.getCheckPreInOrders();
|
|
|
|
|
if (StrUtil.isNotEmpty(orderIds)) {
|
|
|
|
|
String[] orderIdArray = orderIds.split(",");
|
|
|
|
|
List<String> orderList = CollUtil.toList(orderIdArray);
|
|
|
|
|
List<IoCodeEntity> outCodeEntitys = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
List<IoCodeEntity> preInCodeEntities = codeService.findByOrderIds(orderList, null);
|
|
|
|
|
|
|
|
|
|
// 扣减数量
|
|
|
|
|
for (IoCodeEntity preInCodeEntity : preInCodeEntities) {
|
|
|
|
|
for (IoCodeEntity codeEntity : outCodeEntitys) {
|
|
|
|
|
if (preInCodeEntity.getCode().equals(codeEntity.getCode())) {
|
|
|
|
|
int count = preInCodeEntity.getMyCount() - codeEntity.getMyCount();
|
|
|
|
|
int reCount = preInCodeEntity.getMyReCount() - codeEntity.getMyReCount();
|
|
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
preInCodeEntity.setCount(count);
|
|
|
|
|
preInCodeEntity.setReCount(reCount);
|
|
|
|
|
codeEntity.setCount(0);
|
|
|
|
|
codeEntity.setReCount(0);
|
|
|
|
|
} else if (count < 0) {
|
|
|
|
|
preInCodeEntity.setCount(0);
|
|
|
|
|
preInCodeEntity.setReCount(0);
|
|
|
|
|
codeEntity.setCount(-count);
|
|
|
|
|
codeEntity.setReCount(-reCount);
|
|
|
|
|
} else {
|
|
|
|
|
preInCodeEntity.setCount(0);
|
|
|
|
|
preInCodeEntity.setReCount(0);
|
|
|
|
|
codeEntity.setCount(0);
|
|
|
|
|
codeEntity.setReCount(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IoCodeEntity> backCodeList = new ArrayList<>();
|
|
|
|
|
for (IoCodeEntity codeEntity : preInCodeEntities) {
|
|
|
|
|
if (codeEntity.getMyCount() > 0) {
|
|
|
|
|
backCodeList.add(codeEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
genBackOrder(orderEntity, backCodeList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { //按仓库货位退货
|
|
|
|
|
List<IoCodeEntity> backCodeList = new ArrayList<>();
|
|
|
|
|
List<IoCodeEntity> codeList = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
for (IoCodeEntity codeEntity : codeList) {
|
|
|
|
|
int count = invPreinProductDetailService.findCountByCode(codeEntity.getCode());
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
codeEntity.setCount(count);
|
|
|
|
|
codeEntity.setReCount(udiCalCountUtil.getActCount(codeEntity.getNameCode()));
|
|
|
|
|
for (IoCodeEntity codeEntity : preInCodeEntities) {
|
|
|
|
|
if (codeEntity.getMyCount() > 0) {
|
|
|
|
|
backCodeList.add(codeEntity);
|
|
|
|
|
genBackOrder(orderEntity, backCodeList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
genBackOrder(orderEntity, backCodeList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { //按仓库货位退货
|
|
|
|
|
List<IoCodeEntity> backCodeList = new ArrayList<>();
|
|
|
|
|
List<IoCodeEntity> codeList = codeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
for (IoCodeEntity codeEntity : codeList) {
|
|
|
|
|
int count = invPreinProductDetailService.findCountByCode(codeEntity.getCode());
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
codeEntity.setCount(count);
|
|
|
|
|
codeEntity.setReCount(udiCalCountUtil.getActCount(codeEntity.getNameCode()));
|
|
|
|
|
backCodeList.add(codeEntity);
|
|
|
|
|
genBackOrder(orderEntity, backCodeList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验是否是不入库存单据
|
|
|
|
|
if (bussinessTypeEntity.isInStock()) {
|
|
|
|
|
//生成库存
|
|
|
|
@ -829,6 +831,8 @@ public class IoCheckInoutService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
|
|
|
|
|
public void genBackOrder(IoOrderEntity orderEntity, List<IoCodeEntity> backCodeList) {
|
|
|
|
|
if (CollUtil.isEmpty(backCodeList))
|
|
|
|
@ -836,9 +840,14 @@ public class IoCheckInoutService {
|
|
|
|
|
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
if (StrUtil.isNotEmpty(basicBussinessTypeEntity.getPreInBackAction())) {
|
|
|
|
|
IoOrderEntity outOrder = new IoOrderEntity();
|
|
|
|
|
IoCodeEntity codeEntity = backCodeList.get(0);
|
|
|
|
|
outOrder.setId(null);
|
|
|
|
|
outOrder.setMainAction(ConstantType.TYPE_OUT);
|
|
|
|
|
outOrder.setAction(basicBussinessTypeEntity.getAction());
|
|
|
|
|
outOrder.setAction(basicBussinessTypeEntity.getPreInBackAction());
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(Constant.INV_PRE_IN_CODE);
|
|
|
|
|
outOrder.setInvCode(invWarehouseEntity.getCode());
|
|
|
|
|
outOrder.setDeptCode(invWarehouseEntity.getParentId());
|
|
|
|
|
outOrder.setFromCorp(codeEntity.getSupId());
|
|
|
|
|
outOrder.setCreateTime(new Date());
|
|
|
|
|
outOrder.setFromType(ConstantStatus.FROM_BACK);
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(basicBussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|