Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
92a756d19e
|
|
@ -16,7 +16,6 @@ import com.nflg.wms.common.pojo.qo.ComponentPackingEditInputQO;
|
|||
import com.nflg.wms.common.pojo.qo.ComponentPackingInputQO;
|
||||
import com.nflg.wms.common.pojo.qo.ComponentPackingQO;
|
||||
import com.nflg.wms.common.pojo.vo.*;
|
||||
import com.nflg.wms.common.util.PageUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.WmsComponentPacking;
|
||||
import com.nflg.wms.repository.entity.WmsComponentPackingItem;
|
||||
|
|
@ -114,9 +113,7 @@ public class ComponentPackingController {
|
|||
|
||||
/**
|
||||
* 添加零部件的打包信息
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @return {@link InventoryLockVO}
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> savePacking(@Valid @RequestBody ComponentPackingInputQO request) {
|
||||
|
|
@ -195,12 +192,12 @@ public class ComponentPackingController {
|
|||
if (CollectionUtil.isEmpty(tasks)) {
|
||||
return ApiResult.success(Collections.emptyList());
|
||||
}
|
||||
Integer type = bomService.getScanType(packing.getMatnr());
|
||||
// 转换为 VO 对象
|
||||
List<ComponentPackingItemPdaVO> daVos = tasks.stream()
|
||||
.map(item1 -> {
|
||||
ComponentPackingItemPdaVO vo = Convert.convert(ComponentPackingItemPdaVO.class, item1);
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(vo.getIdnrk()));
|
||||
Integer type = bomService.getScanType(vo.getIdnrk());
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(vo.getIdnrk()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,13 @@ import com.nflg.wms.common.pojo.vo.InProduceOrderItemVO;
|
|||
import com.nflg.wms.common.pojo.vo.InProduceOrderMaterialVO;
|
||||
import com.nflg.wms.common.pojo.vo.InProduceOrderVO;
|
||||
import com.nflg.wms.common.util.DateTimeUtil;
|
||||
import com.nflg.wms.common.util.NumberUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.*;
|
||||
import com.nflg.wms.repository.entity.WmsBom;
|
||||
import com.nflg.wms.repository.entity.WmsInProduceOrder;
|
||||
import com.nflg.wms.repository.entity.WmsInProduceOrderItem;
|
||||
import com.nflg.wms.repository.entity.WmsQrCodeMaster;
|
||||
import com.nflg.wms.repository.service.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
|
@ -118,7 +122,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 从SAP查询生产订单信息
|
||||
*
|
||||
* @param no 生产订单号
|
||||
* @return 订单信息
|
||||
*/
|
||||
|
|
@ -129,7 +132,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@Transactional
|
||||
|
|
@ -169,7 +171,7 @@ public class InProduceOrderController extends BaseController {
|
|||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setOrderId(order.getId())
|
||||
.setParentId(parent.getId())
|
||||
.setNum(request.getNum().multiply(it.getNum()))
|
||||
.setNum(it.getNum())
|
||||
.setMaterialNo(it.getNo())
|
||||
.setMaterialDesc(it.getDescribe())
|
||||
.setUnit(request.getMeins())
|
||||
|
|
@ -189,7 +191,7 @@ public class InProduceOrderController extends BaseController {
|
|||
.setMaterialCode(it.getMaterialNo())
|
||||
.setMaterialDescription(it.getMaterialDesc())
|
||||
.setPackagingType((short) 0)
|
||||
.setQuantity(it.getNum())
|
||||
.setQuantity(NumberUtil.multiply(it.getNum(), parent.getNum()))
|
||||
.setUnit(it.getUnit())
|
||||
.setBatchNo(it.getBatchNo())
|
||||
.setSerialNo(it.getSernr())
|
||||
|
|
@ -222,7 +224,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 搜索
|
||||
*
|
||||
* @param request 搜索参数
|
||||
* @return 搜索结果
|
||||
*/
|
||||
|
|
@ -233,7 +234,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取订单的物料列表
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @return 列表
|
||||
*/
|
||||
|
|
@ -252,7 +252,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 订单ID
|
||||
*/
|
||||
@Transactional
|
||||
|
|
@ -269,7 +268,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 导出物料条码pdf(逐个)
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @param type 1:逐个,2:一页
|
||||
*/
|
||||
|
|
@ -378,7 +376,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取订单信息(PDA使用)
|
||||
*
|
||||
* @param no 报工单号
|
||||
*/
|
||||
@GetMapping("getOrderInfo")
|
||||
|
|
@ -398,13 +395,13 @@ public class InProduceOrderController extends BaseController {
|
|||
List<InProduceOrderItemVO> children = list.stream()
|
||||
.filter(child -> Objects.equals(child.getParentId(), it.getId()))
|
||||
.toList();
|
||||
it.setQiTao(CollectionUtil.isNotEmpty(children));
|
||||
Integer type = bomService.getScanType(it.getMaterialNo());
|
||||
it.setQiTao(type > 0);
|
||||
if (Objects.equals(type, 0)) {
|
||||
it.setMustScan(false);
|
||||
}
|
||||
children.forEach(child -> {
|
||||
child.setQiTao(it.isQiTao());
|
||||
child.setQiTao(false);
|
||||
child.setMustScan(it.isMustScan());
|
||||
child.setBinNo(binService.getBinNo(child.getMaterialNo(), child.getFactoryNo(), child.getWarehouseNo()));
|
||||
child.setIsDisableLocation(warehouseService.isEnableLocation(child.getFactoryNo(), child.getWarehouseNo()));
|
||||
|
|
@ -418,7 +415,6 @@ public class InProduceOrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 收货和入库(PDA使用)
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@Transactional
|
||||
|
|
@ -432,19 +428,21 @@ public class InProduceOrderController extends BaseController {
|
|||
List<InProduceOrderItemVO> datas;
|
||||
if (order.getList()) {
|
||||
datas = new ArrayList<>();
|
||||
list.stream().filter(it -> Objects.equals(it.getParentId(), 0L)).forEach(it -> {
|
||||
List<InProduceOrderItemVO> children = list.stream()
|
||||
.filter(child -> Objects.equals(child.getParentId(), it.getId()))
|
||||
.toList();
|
||||
Integer type = bomService.getScanType(it.getMaterialNo());
|
||||
children.forEach(child -> {
|
||||
child.setQiTao(type > 0);
|
||||
if (Objects.equals(type, 0)) {
|
||||
child.setMustScan(false);
|
||||
}
|
||||
});
|
||||
datas.addAll(children);
|
||||
});
|
||||
list.stream().filter(it -> Objects.equals(it.getParentId(), 0L))
|
||||
.forEach(it -> {
|
||||
List<InProduceOrderItemVO> children = list.stream()
|
||||
.filter(child -> Objects.equals(child.getParentId(), it.getId()))
|
||||
.toList();
|
||||
Integer type = bomService.getScanType(it.getMaterialNo());
|
||||
children.forEach(child -> {
|
||||
child.setNum(NumberUtil.multiply(child.getNum(), it.getNum()));
|
||||
child.setQiTao(false);
|
||||
if (Objects.equals(type, 0)) {
|
||||
child.setMustScan(false);
|
||||
}
|
||||
});
|
||||
datas.addAll(children);
|
||||
});
|
||||
} else {
|
||||
datas = list;
|
||||
}
|
||||
|
|
@ -459,9 +457,9 @@ public class InProduceOrderController extends BaseController {
|
|||
List<WmsQrCodeMaster> qrCodeMasters = CollectionUtil.isEmpty(allQrCodes)
|
||||
? Collections.emptyList()
|
||||
: qrCodeMasterService.lambdaQuery()
|
||||
.ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, allQrCodes)
|
||||
.list();
|
||||
.ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, allQrCodes)
|
||||
.list();
|
||||
datas.forEach(it -> {
|
||||
InventoryIn1ItemQO qitem = request.getItems().stream()
|
||||
.filter(item -> Objects.equals(item.getItemId(), it.getId()))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.nflg.wms.admin.repository.InventoryForOutRepository;
|
|||
import com.nflg.wms.admin.repository.OutMaterialScanRecordRespository;
|
||||
import com.nflg.wms.admin.service.BasdeSerialNumberControllerService;
|
||||
import com.nflg.wms.admin.service.SapService;
|
||||
import com.nflg.wms.admin.util.NoUtil;
|
||||
import com.nflg.wms.admin.util.PdfGeneratorUtil;
|
||||
import com.nflg.wms.admin.util.QRCodeUtil;
|
||||
import com.nflg.wms.admin.util.ThymeleafUtil;
|
||||
|
|
@ -105,6 +104,7 @@ public class OutAssistanceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 保存
|
||||
* @return {@link InventoryLockVO}
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("save")
|
||||
|
|
@ -119,6 +119,7 @@ public class OutAssistanceController extends BaseController {
|
|||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(materialNos))
|
||||
.throwMessage("以下物料的申请数量超出限制:" + StrUtil.join(",", materialNos));
|
||||
Map<String, List<SubcontractedOrderDTO>> maps = datas.stream().collect(Collectors.groupingBy(SubcontractedOrderDTO::getKey));
|
||||
List<InventoryLockVO> lockVOS = new ArrayList<>();
|
||||
maps.forEach((key, items) -> {
|
||||
WmsOutAssistance order = Convert.convert(WmsOutAssistance.class, items.get(0));
|
||||
order.setNo(serialNumberControllerService.generateSerialNumber(16));
|
||||
|
|
@ -127,11 +128,35 @@ public class OutAssistanceController extends BaseController {
|
|||
outAssistanceService.save(order);
|
||||
items.forEach(item -> {
|
||||
WmsOutAssistanceItem data = Convert.convert(WmsOutAssistanceItem.class, item);
|
||||
data.setLeft(data.getNum());
|
||||
data.setOrderId(order.getId());
|
||||
outAssistanceItemService.save(data);
|
||||
RLock lock = redissonClient.getLock(StrUtil.format("lock:inventory:{}:{}:{}", order.getWerks(), order.getLgort1(), item.getMatnr1()));
|
||||
try {
|
||||
// 等待5秒获取锁,10秒后自动释放
|
||||
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
|
||||
if (inventoryService.getNumOne(order.getWerks(), order.getLgort1(), item.getMatnr1()).compareTo(data.getNum()) < 0) {
|
||||
List<InventoryLockVO> itemLocks = inventoryService.getLockList(order.getWerks(), order.getLgort1(), item.getMatnr1());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getMatnr1());
|
||||
lockVOS.addAll(itemLocks);
|
||||
}else {
|
||||
data.setLeft(data.getNum());
|
||||
data.setOrderId(order.getId());
|
||||
outAssistanceItemService.save(data);
|
||||
}
|
||||
} else {
|
||||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存单据出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(lockVOS)) {
|
||||
throw new DataAlertException(STATE.OutOfStock, lockVOS);
|
||||
}
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +236,7 @@ public class OutAssistanceController extends BaseController {
|
|||
.setMatnr(item.getMatnr1())
|
||||
.setMeins(item.getMeins())
|
||||
.setNum(item.getLeft());
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(item.getMatnr1()));
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(item.getMatnr1()));
|
||||
}
|
||||
|
|
@ -230,10 +255,10 @@ public class OutAssistanceController extends BaseController {
|
|||
public ApiResult<Void> submit(@Valid @RequestBody OutProduceSubmitQO request) {
|
||||
WmsOutAssistance order = outAssistanceService.lambdaQuery().eq(WmsOutAssistance::getNo, request.getNo()).one();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
|
||||
Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
.throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
// Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
// matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
// .throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
WmsOutAssistanceTicket ticket = new WmsOutAssistanceTicket()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setNo(serialNumberControllerService.generateSerialNumber(17))
|
||||
|
|
@ -354,36 +379,6 @@ public class OutAssistanceController extends BaseController {
|
|||
});
|
||||
}
|
||||
});
|
||||
List<InventoryLockVO> lockVOS = new ArrayList<>();
|
||||
records.stream()
|
||||
.collect(Collectors.groupingBy(OutMaterialScanRecord::getKey10))
|
||||
.forEach((key, vs) -> {
|
||||
OutMaterialScanRecord info = vs.get(0);
|
||||
BigDecimal lockNum = vs.stream().map(OutMaterialScanRecord::getNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
RLock lock = redissonClient.getLock(StrUtil.format("lock:inventory:{}:{}:{}", info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()));
|
||||
try {
|
||||
// 等待5秒获取锁,10秒后自动释放
|
||||
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
|
||||
if (inventoryService.getNumOne(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()).compareTo(lockNum) < 0) {
|
||||
List<InventoryLockVO> itemLocks = inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + info.getMaterialNo());
|
||||
lockVOS.addAll(itemLocks);
|
||||
}
|
||||
} else {
|
||||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存生产领料单出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(lockVOS)) {
|
||||
throw new DataAlertException(STATE.OutOfStock, lockVOS);
|
||||
}
|
||||
outAssistanceItemService.updateBatchById(datas);
|
||||
outAssistanceTicketItemService.saveBatch(ticketItems);
|
||||
outAssistanceTicketService.save(ticket);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.nflg.wms.admin.repository.InventoryForOutRepository;
|
|||
import com.nflg.wms.admin.repository.OutMaterialScanRecordRespository;
|
||||
import com.nflg.wms.admin.service.BasdeSerialNumberControllerService;
|
||||
import com.nflg.wms.admin.service.SapService;
|
||||
import com.nflg.wms.admin.util.NoUtil;
|
||||
import com.nflg.wms.admin.util.PdfGeneratorUtil;
|
||||
import com.nflg.wms.admin.util.QRCodeUtil;
|
||||
import com.nflg.wms.admin.util.ThymeleafUtil;
|
||||
|
|
@ -108,6 +107,7 @@ public class OutCostCenterController extends BaseController {
|
|||
|
||||
/**
|
||||
* 保存
|
||||
* @return {@link InventoryLockVO}
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("save")
|
||||
|
|
@ -121,6 +121,7 @@ public class OutCostCenterController extends BaseController {
|
|||
});
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(materialNos))
|
||||
.throwMessage("以下物料的申请数量超出限制:" + StrUtil.join(",", materialNos));
|
||||
List<InventoryLockVO> lockVOS = new ArrayList<>();
|
||||
Map<String, List<DepartmentMaterialRequisitionDTO>> maps = datas.stream().collect(Collectors.groupingBy(DepartmentMaterialRequisitionDTO::getKey1));
|
||||
maps.forEach((key, items) -> {
|
||||
WmsOutCostcenter order = Convert.convert(WmsOutCostcenter.class, items.get(0));
|
||||
|
|
@ -130,11 +131,35 @@ public class OutCostCenterController extends BaseController {
|
|||
outCostcenterService.save(order);
|
||||
items.forEach(item -> {
|
||||
WmsOutCostcenterItem data = Convert.convert(WmsOutCostcenterItem.class, item);
|
||||
data.setLeft(data.getNum());
|
||||
data.setOrderId(order.getId());
|
||||
outCostcenterItemService.save(data);
|
||||
RLock lock = redissonClient.getLock(StrUtil.format("lock:inventory:{}:{}:{}", order.getWerks(), data.getLgort(), data.getMatnr()));
|
||||
try {
|
||||
// 等待5秒获取锁,10秒后自动释放
|
||||
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
|
||||
if (inventoryService.getNumOne(order.getWerks(), data.getLgort(), data.getMatnr()).compareTo(data.getNum()) < 0) {
|
||||
List<InventoryLockVO> itemLocks = inventoryService.getLockList(order.getWerks(), data.getLgort(), data.getMatnr());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + data.getMatnr());
|
||||
lockVOS.addAll(itemLocks);
|
||||
} else {
|
||||
data.setLeft(data.getNum());
|
||||
data.setOrderId(order.getId());
|
||||
outCostcenterItemService.save(data);
|
||||
}
|
||||
} else {
|
||||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存单据出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(lockVOS)) {
|
||||
throw new DataAlertException(STATE.OutOfStock, lockVOS);
|
||||
}
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +238,7 @@ public class OutCostCenterController extends BaseController {
|
|||
.setMatnr(item.getMatnr())
|
||||
.setNum(item.getLeft())
|
||||
.setMeins(item.getMeins());
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(item.getMatnr()));
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(item.getMatnr()));
|
||||
}
|
||||
|
|
@ -232,10 +257,10 @@ public class OutCostCenterController extends BaseController {
|
|||
public ApiResult<Void> submit(@Valid @RequestBody OutProduceSubmitQO request) {
|
||||
WmsOutCostcenter order = outCostcenterService.lambdaQuery().eq(WmsOutCostcenter::getNo, request.getNo()).one();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
|
||||
Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
.throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
// Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
// matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
// .throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
WmsOutCostcenterTicket ticket = new WmsOutCostcenterTicket()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setNo(serialNumberControllerService.generateSerialNumber(15))
|
||||
|
|
@ -253,7 +278,9 @@ public class OutCostCenterController extends BaseController {
|
|||
.flatMap(Collection::stream)
|
||||
.map(QRCodeQO::getContent)
|
||||
.collect(Collectors.toSet());
|
||||
List<WmsQrCodeMaster> qrCodeMasters = CollectionUtil.isEmpty(allQrCodes) ? Collections.emptyList() : qrCodeMasterService.lambdaQuery()
|
||||
List<WmsQrCodeMaster> qrCodeMasters = CollectionUtil.isEmpty(allQrCodes)
|
||||
? Collections.emptyList() :
|
||||
qrCodeMasterService.lambdaQuery()
|
||||
.eq(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, allQrCodes)
|
||||
.list();
|
||||
|
|
@ -348,36 +375,6 @@ public class OutCostCenterController extends BaseController {
|
|||
});
|
||||
}
|
||||
});
|
||||
List<InventoryLockVO> lockVOS = new ArrayList<>();
|
||||
records.stream()
|
||||
.collect(Collectors.groupingBy(OutMaterialScanRecord::getKey10))
|
||||
.forEach((key, vs) -> {
|
||||
OutMaterialScanRecord info = vs.get(0);
|
||||
BigDecimal lockNum = vs.stream().map(OutMaterialScanRecord::getNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
RLock lock = redissonClient.getLock(StrUtil.format("lock:inventory:{}:{}:{}", info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()));
|
||||
try {
|
||||
// 等待5秒获取锁,10秒后自动释放
|
||||
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
|
||||
if (inventoryService.getNumOne(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo()).compareTo(lockNum) < 0) {
|
||||
List<InventoryLockVO> itemLocks = inventoryService.getLockList(info.getFactoryNo(), info.getWarehouseNo(), info.getMaterialNo());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + info.getMaterialNo());
|
||||
lockVOS.addAll(itemLocks);
|
||||
}
|
||||
} else {
|
||||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存生产领料单出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(lockVOS)) {
|
||||
throw new DataAlertException(STATE.OutOfStock, lockVOS);
|
||||
}
|
||||
outCostcenterItemService.updateBatchById(datas);
|
||||
outCostcenterTicketItemService.saveBatch(ticketItems);
|
||||
outCostcenterTicketService.save(ticket);
|
||||
|
|
@ -433,17 +430,17 @@ public class OutCostCenterController extends BaseController {
|
|||
.setFactoryNo(list.get(0).getFactoryNo())
|
||||
.setWarehouseNo(list.get(0).getWarehouseNo())
|
||||
.setBinLocation(list.get(0).isQiTao() ? list.get(0).getBinNo() : qrCodeMasters.stream()
|
||||
.filter(qr -> StrUtil.equals(qr.getBarcodeCode(), list.get(0).getUniqNo()))
|
||||
.findFirst()
|
||||
.map(WmsQrCodeMaster::getBinLocation)
|
||||
.orElse("")
|
||||
.filter(qr -> StrUtil.equals(qr.getBarcodeCode(), list.get(0).getUniqNo()))
|
||||
.findFirst()
|
||||
.map(WmsQrCodeMaster::getBinLocation)
|
||||
.orElse("")
|
||||
)
|
||||
.setNum(list.stream().map(OutMaterialScanRecord::getNum).reduce(BigDecimal.ZERO, BigDecimal::add))
|
||||
).toList()
|
||||
);
|
||||
Map<String, List<OutMaterialScanRecord>> dmaps = records.stream().collect(Collectors.groupingBy(OutMaterialScanRecord::getKey7));
|
||||
OptRecordDTO optRecordDTO = new OptRecordDTO();
|
||||
optRecordDTO.setOperationType((short)1)
|
||||
optRecordDTO.setOperationType((short) 1)
|
||||
.setOrderId(order.getNo());
|
||||
optRecordService.add(optRecordDTO);
|
||||
C_MaterialOutboundDTO vo = sapService.ZWM00_MB115(new C_MaterialOutboundQO()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ import com.nflg.wms.common.exception.NflgException;
|
|||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.document.OutMaterialScanRecord;
|
||||
import com.nflg.wms.common.pojo.dto.*;
|
||||
import com.nflg.wms.common.pojo.dto.InventoryForOutDTO;
|
||||
import com.nflg.wms.common.pojo.dto.InventoryInDTO;
|
||||
import com.nflg.wms.common.pojo.dto.InventoryOutDTO;
|
||||
import com.nflg.wms.common.pojo.dto.OptRecordDTO;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.*;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
|
|
@ -46,7 +49,6 @@ import java.io.IOException;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -365,7 +367,7 @@ public class OutProduceController extends BaseController {
|
|||
.setMeins(item.getMeins())
|
||||
.setNum(item.getSqsl().subtract(item.getNum()));
|
||||
Integer type = bomService.getScanType(item.getMatnr());
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(item.getMatnr()));
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(item.getMatnr()));
|
||||
}
|
||||
|
|
@ -384,10 +386,10 @@ public class OutProduceController extends BaseController {
|
|||
public ApiResult<Void> submit(@Valid @RequestBody OutProduceSubmitQO request) {
|
||||
WmsOutProduce order = outProduceService.lambdaQuery().eq(WmsOutProduce::getNo, request.getNo()).one();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
|
||||
Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
.throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
// Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
// matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
// .throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
WmsOutProduceTicket ticket = new WmsOutProduceTicket()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setNo(serialNumberControllerService.generateSerialNumber(21))
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public class TransferCompanyController extends BaseController {
|
|||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存生产领料单出错", e);
|
||||
log.error("保存出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
|
|
@ -269,7 +269,7 @@ public class TransferCompanyController extends BaseController {
|
|||
.setMaktx(item.getMaktx())
|
||||
.setNum(item.getLeft())
|
||||
.setMeins(item.getMeins());
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(item.getMatnr()));
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(item.getMatnr()));
|
||||
}
|
||||
|
|
@ -288,10 +288,10 @@ public class TransferCompanyController extends BaseController {
|
|||
public ApiResult<Void> submitForOut(@Valid @RequestBody OutProduceSubmitQO request) {
|
||||
WmsTransferCompany order = transferCompanyService.lambdaQuery().eq(WmsTransferCompany::getNo, request.getNo()).one();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("转储单不存在");
|
||||
Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
.throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
// Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
// matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
// .throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
List<WmsTransferCompanyItem> datas = transferCompanyItemService.getList(order.getId());
|
||||
List<OutMaterialScanRecord> records = new ArrayList<>();
|
||||
List<WmsTransferCompanyTicketItem> ticketItems = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public class TransferFactoryController extends BaseController {
|
|||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存生产领料单出错", e);
|
||||
log.error("保存出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
|
|
@ -268,7 +268,7 @@ public class TransferFactoryController extends BaseController {
|
|||
.setMeins(item.getMeins())
|
||||
.setBinIn(StrUtil.join("/", storageService.getBinNo(item.getMatnr(), order.getWerks(), order.getUmlgo())))
|
||||
.setBinOut(StrUtil.join("/", storageService.getBinNo(item.getMatnr(), order.getWerks(), order.getLgort())));
|
||||
vo.setQiTao(type > 0);
|
||||
vo.setQiTao(bomService.isQiTao(item.getMatnr()));
|
||||
if (Objects.equals(type, 1)) {
|
||||
vo.setChildren(bomService.getChildrenVO(item.getMatnr()));
|
||||
}
|
||||
|
|
@ -287,10 +287,10 @@ public class TransferFactoryController extends BaseController {
|
|||
public ApiResult<Void> submitForOut(@Valid @RequestBody OutProduceSubmitQO request) {
|
||||
WmsTransferFactory order = transferFactoryService.lambdaQuery().eq(WmsTransferFactory::getNo, request.getNo()).one();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("调拨单不存在");
|
||||
Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
.throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
// Set<String> matnrs = request.getItems().stream().map(OutProduceSubmitItemQO::getMaterialNo).collect(Collectors.toSet());
|
||||
// matnrs.removeAll(request.getRecommendBatch().stream().map(InventoryForOutVO::getMaterialNo).collect(Collectors.toSet()));
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(matnrs))
|
||||
// .throwMessage("以下物料无库存,不能出库:" + StrUtil.join(",", matnrs));
|
||||
List<WmsTransferFactoryItem> datas = transferFactoryItemService.getList(order.getId());
|
||||
List<OutMaterialScanRecord> records = new ArrayList<>();
|
||||
WmsTransferFactoryTicket ticket = new WmsTransferFactoryTicket()
|
||||
|
|
|
|||
|
|
@ -2,27 +2,38 @@ package com.nflg.wms.admin.service;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.DataAlertException;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.qo.ComponentPackingEditInputQO;
|
||||
import com.nflg.wms.common.pojo.qo.ComponentPackingInputQO;
|
||||
import com.nflg.wms.common.pojo.qo.ComponentPackingItemEditInputQO;
|
||||
import com.nflg.wms.common.pojo.vo.InventoryLockVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.WmsComponentPacking;
|
||||
import com.nflg.wms.repository.entity.WmsComponentPackingItem;
|
||||
import com.nflg.wms.repository.service.IWmsComponentPackingItemService;
|
||||
import com.nflg.wms.repository.service.IWmsComponentPackingService;
|
||||
import com.nflg.wms.repository.service.IWmsInventoryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.commons.util.IdUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ComponentPackingControllerService {
|
||||
@Resource
|
||||
|
|
@ -34,6 +45,12 @@ public class ComponentPackingControllerService {
|
|||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@Resource
|
||||
private IWmsInventoryService inventoryService;
|
||||
|
||||
@Transactional
|
||||
public void savePacking(@Valid ComponentPackingInputQO request) {
|
||||
WmsComponentPacking wmsComponentPacking = new WmsComponentPacking();
|
||||
|
|
@ -65,32 +82,57 @@ public class ComponentPackingControllerService {
|
|||
wmsComponentPacking.setCreateId(UserUtil.getUserId());
|
||||
wmsComponentPacking.setCreateTime(LocalDateTime.now());
|
||||
wmsComponentPacking.setFactoryNo(request.getFactoryNo());
|
||||
List<WmsComponentPackingItem> wmsComponentPackingItems = request.getItems().stream()
|
||||
.map(item -> new WmsComponentPackingItem()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setItemIndex(item.getIndex())
|
||||
.setVbeln(item.getVbeln())
|
||||
.setPosnr(item.getPosnr())
|
||||
.setIdnrk(item.getIdnrk())
|
||||
.setOjtxb(item.getOjtxb())
|
||||
.setMeins(item.getMeins())
|
||||
.setMenge(item.getMenge())
|
||||
.setAtwrt(item.getAtwrt())
|
||||
.setZatwrt(item.getZatwrt())
|
||||
.setZxiah(item.getZxiah())
|
||||
.setZtext(item.getZtext())
|
||||
.setPotx2(item.getPotx2())
|
||||
.setPmenge(item.getPmenge())
|
||||
.setLgpbe(item.getLgpbe())
|
||||
.setLgort(item.getLgort())
|
||||
.setLgobe(item.getLgobe())
|
||||
.setOutQty(new BigDecimal(0))
|
||||
.setPackingId(wmsComponentPacking.getId())
|
||||
).toList();
|
||||
|
||||
List<InventoryLockVO> lockVOS = new ArrayList<>();
|
||||
request.getItems().forEach(item -> {
|
||||
RLock lock = redissonClient.getLock(StrUtil.format("lock:inventory:{}:{}:{}", wmsComponentPacking.getFactoryNo(), item.getLgort(), item.getIdnrk()));
|
||||
try {
|
||||
// 等待5秒获取锁,10秒后自动释放
|
||||
if (lock.tryLock(5, 10, TimeUnit.SECONDS)) {
|
||||
if (inventoryService.getNumOne(wmsComponentPacking.getFactoryNo(), item.getLgort(), item.getIdnrk()).compareTo(item.getMenge()) < 0) {
|
||||
List<InventoryLockVO> itemLocks = inventoryService.getLockList(wmsComponentPacking.getFactoryNo(), item.getLgort(), item.getIdnrk());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(itemLocks)).throwMessage("库存不足:" + item.getIdnrk());
|
||||
lockVOS.addAll(itemLocks);
|
||||
} else {
|
||||
wmsComponentPackingItemService.save(
|
||||
new WmsComponentPackingItem()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setItemIndex(item.getIndex())
|
||||
.setVbeln(item.getVbeln())
|
||||
.setPosnr(item.getPosnr())
|
||||
.setIdnrk(item.getIdnrk())
|
||||
.setOjtxb(item.getOjtxb())
|
||||
.setMeins(item.getMeins())
|
||||
.setMenge(item.getMenge())
|
||||
.setAtwrt(item.getAtwrt())
|
||||
.setZatwrt(item.getZatwrt())
|
||||
.setZxiah(item.getZxiah())
|
||||
.setZtext(item.getZtext())
|
||||
.setPotx2(item.getPotx2())
|
||||
.setPmenge(item.getPmenge())
|
||||
.setLgpbe(item.getLgpbe())
|
||||
.setLgort(item.getLgort())
|
||||
.setLgobe(item.getLgobe())
|
||||
.setOutQty(new BigDecimal(0))
|
||||
.setPackingId(wmsComponentPacking.getId())
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new NflgException(STATE.BusinessError, "获取锁失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存单据出错", e);
|
||||
throw new NflgException(STATE.BusinessError, e.getMessage());
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(lockVOS)) {
|
||||
throw new DataAlertException(STATE.OutOfStock, lockVOS);
|
||||
}
|
||||
// 直接保存
|
||||
wmscomponentPackingService.save(wmsComponentPacking);
|
||||
wmsComponentPackingItemService.saveBatch(wmsComponentPackingItems);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package com.nflg.wms.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
|
|
@ -157,6 +157,7 @@ public class WmsComponentPacking implements Serializable {
|
|||
/**
|
||||
* 所属工厂
|
||||
*/
|
||||
@NotBlank
|
||||
private String factoryNo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ public interface IWmsBomService extends IService<WmsBom> {
|
|||
// boolean isParent(String materialNo);
|
||||
|
||||
Integer getScanType(String materialNo);
|
||||
|
||||
boolean isQiTao(String materialNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,4 +188,12 @@ public class WmsBomServiceImpl extends ServiceImpl<WmsBomMapper, WmsBom> impleme
|
|||
).orElse(new WmsBom().setScanType(-1))
|
||||
.getScanType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQiTao(String materialNo) {
|
||||
return lambdaQuery()
|
||||
.eq(WmsBom::getParentId, 0)
|
||||
.eq(WmsBom::getNo, materialNo)
|
||||
.exists();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue