refactor(transfer): 优化转储单无扫描记录的数据结构和查询逻辑
- 移除未使用的 TransferFactoryNoScanRecord 和 ApiMark 注解导入 - 将 TransferCompanyNoScanRecord 中的 id 字段重命名为 orderId,ItemId 重命名为 itemId - 将 TransferFactoryNoScanRecord 中的 id 字段重命名为 orderId,ItemId 重命名为 itemId - 更新 TransferCompanyNoScanRecordRespository 查询方法名从 getTransferCompanyNoScanRecordBy 到 findByOrderIdAndItemId - 更新 TransferFactoryNoScanRecordRespository 查询方法名从 getTransferFactoryNoScanRecordBy 到 findByOrderIdAndItemId - 在 TransferCompanyTicketVO 和 TransferFactoryTicketVO 中添加 orderId 字段 - 修正控制器中的 NPE 检查逻辑,简化 Objects.isNull 判断 - 更新数据库查询映射,添加 orderId 字段到 VO 查询结果中 - 统一字段引用从 id 到 orderId 的使用一致性
This commit is contained in:
parent
a12a36f479
commit
0a2f4136da
|
|
@ -31,7 +31,6 @@ import com.nflg.wms.common.pojo.PageData;
|
|||
import com.nflg.wms.common.pojo.document.InMaterialScanRecord;
|
||||
import com.nflg.wms.common.pojo.document.OutMaterialScanRecord;
|
||||
import com.nflg.wms.common.pojo.document.TransferCompanyNoScanRecord;
|
||||
import com.nflg.wms.common.pojo.document.TransferFactoryNoScanRecord;
|
||||
import com.nflg.wms.common.pojo.dto.*;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.*;
|
||||
|
|
@ -41,7 +40,6 @@ import com.nflg.wms.common.util.VUtil;
|
|||
import com.nflg.wms.repository.entity.*;
|
||||
import com.nflg.wms.repository.service.*;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import com.nflg.wms.starter.annotation.ApiMark;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
@ -123,15 +121,16 @@ public class TransferCompanyController extends BaseController {
|
|||
|
||||
@Resource
|
||||
private TransferCompanyNoScanRecordRespository transferCompanyNoScanRecordRespository;
|
||||
|
||||
/**
|
||||
* 查询SAP订单数据
|
||||
*/
|
||||
@PostMapping("searchSAP")
|
||||
public ApiResult<PageData<AllocationOrderDTO>> searchSAP0(@Valid @RequestBody AllocationOrderQO request) {
|
||||
List<AllocationOrderDTO> datas = sapService.zwm3a15(request);
|
||||
if (CollectionUtil.isNotEmpty(datas)){
|
||||
if (CollectionUtil.isNotEmpty(datas)) {
|
||||
datas.forEach(dto -> {
|
||||
dto.setLockedNum(transferCompanyItemService.getLockedNum(dto.getEbeln(),dto.getEbelp()));
|
||||
dto.setLockedNum(transferCompanyItemService.getLockedNum(dto.getEbeln(), dto.getEbelp()));
|
||||
});
|
||||
}
|
||||
return ApiResult.success(PageUtil.Page(datas, request.getPage(), request.getPageSize()));
|
||||
|
|
@ -635,13 +634,13 @@ public class TransferCompanyController extends BaseController {
|
|||
transferCompanyTicketService.save(ticket);
|
||||
submitSap(order, ticket, records, datas, ticketItems, Collections.emptyList());
|
||||
|
||||
if (!Objects.isNull(request) && CollectionUtil.isNotEmpty(request.getItems())) {
|
||||
if (CollectionUtil.isNotEmpty(request.getItems())) {
|
||||
List<TransferCompanyNoScanRecord> temRecords = new ArrayList<>();
|
||||
request.getItems().forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(item.getDatas())) {
|
||||
item.getDatas().forEach(data -> {
|
||||
temRecords.add(new TransferCompanyNoScanRecord()
|
||||
.setId(request.getId())
|
||||
.setOrderId(request.getId())
|
||||
.setItemId(item.getOrderItemId())
|
||||
.setNum(data.getNum())
|
||||
.setBatchNo(data.getBatchNo())
|
||||
|
|
@ -649,9 +648,9 @@ public class TransferCompanyController extends BaseController {
|
|||
.setBinNo(data.getBinNo())
|
||||
);
|
||||
});
|
||||
} });
|
||||
if(CollectionUtil.isNotEmpty(temRecords))
|
||||
{
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(temRecords)) {
|
||||
transferCompanyNoScanRecordRespository.saveAll(temRecords);
|
||||
}
|
||||
|
||||
|
|
@ -717,24 +716,21 @@ public class TransferCompanyController extends BaseController {
|
|||
*/
|
||||
@GetMapping("pda/getTicketForIn")
|
||||
public ApiResult<List<TransferCompanyTicketVO>> getTicketForOut(@Valid @RequestParam @NotBlank String no) {
|
||||
List<TransferCompanyTicketVO> vos=transferCompanyTicketService.getVOByOrderNo(no);
|
||||
if(CollectionUtil.isNotEmpty(vos))
|
||||
{
|
||||
List<TransferCompanyTicketVO> vos = transferCompanyTicketService.getVOByOrderNo(no);
|
||||
if (CollectionUtil.isNotEmpty(vos)) {
|
||||
vos.forEach(p -> {
|
||||
List<NoScanningItemQO> items = new ArrayList<>();
|
||||
List<WmsTransferCompanyItem> wmsItems=transferCompanyItemService.lambdaQuery()
|
||||
.eq(WmsTransferCompanyItem::getOrderId, p.getId())
|
||||
List<WmsTransferCompanyItem> wmsItems = transferCompanyItemService.lambdaQuery()
|
||||
.eq(WmsTransferCompanyItem::getOrderId, p.getOrderId())
|
||||
.list();
|
||||
if(CollectionUtil.isNotEmpty(wmsItems))
|
||||
{
|
||||
if (CollectionUtil.isNotEmpty(wmsItems)) {
|
||||
wmsItems.forEach(wmsItem -> {
|
||||
List<NoScanningItemDataQO> dataQOS=new ArrayList<>();
|
||||
List<TransferCompanyNoScanRecord> mongoRecords=
|
||||
transferCompanyNoScanRecordRespository.getTransferCompanyNoScanRecordBy(
|
||||
p.getId(),
|
||||
List<NoScanningItemDataQO> dataQOS = new ArrayList<>();
|
||||
List<TransferCompanyNoScanRecord> mongoRecords =
|
||||
transferCompanyNoScanRecordRespository.findByOrderIdAndItemId(
|
||||
p.getOrderId(),
|
||||
wmsItem.getId());
|
||||
if(CollectionUtil.isNotEmpty(mongoRecords))
|
||||
{
|
||||
if (CollectionUtil.isNotEmpty(mongoRecords)) {
|
||||
mongoRecords.forEach(mongoRecord -> {
|
||||
dataQOS.add(new NoScanningItemDataQO()
|
||||
.setBinNo(mongoRecord.getBinNo())
|
||||
|
|
@ -763,7 +759,6 @@ public class TransferCompanyController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
return ApiResult.success(vos);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,9 @@ public class TransferFactoryController extends BaseController {
|
|||
private NoScanningBaseControllerService noScanningBaseControllerService;
|
||||
|
||||
@Resource
|
||||
private TransferFactoryNoScanRecordRespository transferFactoryNoScanRecordRespository;;
|
||||
private TransferFactoryNoScanRecordRespository transferFactoryNoScanRecordRespository;
|
||||
;
|
||||
|
||||
/**
|
||||
* 查询SAP领料订单数据
|
||||
*/
|
||||
|
|
@ -664,13 +666,13 @@ public class TransferFactoryController extends BaseController {
|
|||
.setNum(list.stream().map(OutMaterialScanRecord::getNum).reduce(BigDecimal.ZERO, BigDecimal::add))
|
||||
).toList()
|
||||
);
|
||||
if (!Objects.isNull(request) && CollectionUtil.isNotEmpty(request.getItems())) {
|
||||
if (CollectionUtil.isNotEmpty(request.getItems())) {
|
||||
List<TransferFactoryNoScanRecord> temRecords = new ArrayList<>();
|
||||
request.getItems().forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(item.getDatas())) {
|
||||
item.getDatas().forEach(data -> {
|
||||
temRecords.add(new TransferFactoryNoScanRecord()
|
||||
.setId(request.getId())
|
||||
.setOrderId(request.getId())
|
||||
.setItemId(item.getOrderItemId())
|
||||
.setNum(data.getNum())
|
||||
.setBatchNo(data.getBatchNo())
|
||||
|
|
@ -678,9 +680,9 @@ public class TransferFactoryController extends BaseController {
|
|||
.setBinNo(data.getBinNo())
|
||||
);
|
||||
});
|
||||
} });
|
||||
if(CollectionUtil.isNotEmpty(temRecords))
|
||||
{
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(temRecords)) {
|
||||
transferFactoryNoScanRecordRespository.saveAll(temRecords);
|
||||
}
|
||||
|
||||
|
|
@ -785,40 +787,37 @@ public class TransferFactoryController extends BaseController {
|
|||
*/
|
||||
@GetMapping("pda/getTicketForIn")
|
||||
public ApiResult<List<TransferFactoryTicketVO>> getTicketForOut(@Valid @RequestParam @NotBlank String no) {
|
||||
List<TransferFactoryTicketVO> vos=transferFactoryTicketService.getVOByOrderNo(no);
|
||||
if(CollectionUtil.isNotEmpty(vos))
|
||||
{
|
||||
List<TransferFactoryTicketVO> vos = transferFactoryTicketService.getVOByOrderNo(no);
|
||||
if (CollectionUtil.isNotEmpty(vos)) {
|
||||
vos.forEach(p -> {
|
||||
List<NoScanningItemQO> items = new ArrayList<>();
|
||||
List<WmsTransferFactoryItem> wmsItems=transferFactoryItemService.lambdaQuery()
|
||||
.eq(WmsTransferFactoryItem::getOrderId, p.getId())
|
||||
List<WmsTransferFactoryItem> wmsItems = transferFactoryItemService.lambdaQuery()
|
||||
.eq(WmsTransferFactoryItem::getOrderId, p.getOrderId())
|
||||
.list();
|
||||
if(CollectionUtil.isNotEmpty(wmsItems))
|
||||
{
|
||||
wmsItems.forEach(wmsItem -> {
|
||||
List<NoScanningItemDataQO> dataQOS=new ArrayList<>();
|
||||
List<TransferFactoryNoScanRecord> mongoRecords=
|
||||
transferFactoryNoScanRecordRespository.getTransferFactoryNoScanRecordBy(
|
||||
p.getId(),
|
||||
wmsItem.getId());
|
||||
if(CollectionUtil.isNotEmpty(mongoRecords))
|
||||
{
|
||||
mongoRecords.forEach(mongoRecord -> {
|
||||
dataQOS.add(new NoScanningItemDataQO()
|
||||
.setBinNo(mongoRecord.getBinNo())
|
||||
.setNum(mongoRecord.getNum())
|
||||
.setSerialNo(mongoRecord.getSerialNo())
|
||||
.setBatchNo(mongoRecord.getBatchNo())
|
||||
);
|
||||
});
|
||||
}
|
||||
items.add(new NoScanningItemQO()
|
||||
.setOrderItemId(wmsItem.getId())
|
||||
.setWarehouseNo(p.getUmlgo())
|
||||
.setMaterialNo(wmsItem.getMatnr())
|
||||
.setDatas(dataQOS)
|
||||
);
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(wmsItems)) {
|
||||
wmsItems.forEach(wmsItem -> {
|
||||
List<NoScanningItemDataQO> dataQOS = new ArrayList<>();
|
||||
List<TransferFactoryNoScanRecord> mongoRecords =
|
||||
transferFactoryNoScanRecordRespository.findByOrderIdAndItemId(
|
||||
p.getOrderId(),
|
||||
wmsItem.getId());
|
||||
if (CollectionUtil.isNotEmpty(mongoRecords)) {
|
||||
mongoRecords.forEach(mongoRecord -> {
|
||||
dataQOS.add(new NoScanningItemDataQO()
|
||||
.setBinNo(mongoRecord.getBinNo())
|
||||
.setNum(mongoRecord.getNum())
|
||||
.setSerialNo(mongoRecord.getSerialNo())
|
||||
.setBatchNo(mongoRecord.getBatchNo())
|
||||
);
|
||||
});
|
||||
}
|
||||
items.add(new NoScanningItemQO()
|
||||
.setOrderItemId(wmsItem.getId())
|
||||
.setWarehouseNo(p.getUmlgo())
|
||||
.setMaterialNo(wmsItem.getMatnr())
|
||||
.setDatas(dataQOS)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -826,7 +825,7 @@ public class TransferFactoryController extends BaseController {
|
|||
.setId(p.getId())
|
||||
.setNo(p.getNo())
|
||||
.setItems(items);
|
||||
p.noScannings.add(qo);
|
||||
p.noScannings.add(qo);
|
||||
});
|
||||
}
|
||||
return ApiResult.success(vos);
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ import java.util.List;
|
|||
@Repository
|
||||
public interface TransferCompanyNoScanRecordRespository
|
||||
extends MongoRepository<TransferCompanyNoScanRecord, String> {
|
||||
List<TransferCompanyNoScanRecord> getTransferCompanyNoScanRecordBy(Long id, Long itemId);
|
||||
List<TransferCompanyNoScanRecord> findByOrderIdAndItemId(Long id, Long itemId);
|
||||
}
|
||||
|
|
@ -9,5 +9,5 @@ import java.util.List;
|
|||
@Repository
|
||||
public interface TransferFactoryNoScanRecordRespository
|
||||
extends MongoRepository<TransferFactoryNoScanRecord, String> {
|
||||
List<TransferFactoryNoScanRecord> getTransferFactoryNoScanRecordBy(Long id, Long itemId);
|
||||
List<TransferFactoryNoScanRecord> findByOrderIdAndItemId(Long id, Long itemId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ public class TransferCompanyNoScanRecord {
|
|||
/**
|
||||
* 转储单ID
|
||||
*/
|
||||
private Long id;
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 转储单项目Id
|
||||
*/
|
||||
private Long ItemId;
|
||||
private Long itemId;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ public class TransferFactoryNoScanRecord {
|
|||
/**
|
||||
* 转储单ID
|
||||
*/
|
||||
private Long id;
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 转储单项目Id
|
||||
*/
|
||||
private Long ItemId;
|
||||
private Long itemId;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ public class TransferCompanyTicketVO {
|
|||
|
||||
private Long id;
|
||||
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 转储单单号
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ public class TransferFactoryTicketVO {
|
|||
|
||||
private Long id;
|
||||
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 调拨单单号
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
</select>
|
||||
|
||||
<select id="getVOByOrderNo" resultType="com.nflg.wms.common.pojo.vo.TransferCompanyTicketVO">
|
||||
select tct.id,tct.no as "ticket_no",tct.create_by,tct.create_time,tct.update_by,tct.update_time,tct.mat_doc
|
||||
select tct.id,tc.id as "orderId",tct.no as "ticket_no",tct.create_by,tct.create_time,tct.update_by,tct.update_time,tct.mat_doc
|
||||
,tct.doc_year,tct.state,tct.finish,tct.audit_state,tct.audit_by,tct.audit_time,tct.audit_msg,tc.*
|
||||
from wms_transfer_company tc
|
||||
inner join wms_transfer_company_ticket tct on tc.id = tct.order_id
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
</select>
|
||||
|
||||
<select id="getVOByOrderNo" resultType="com.nflg.wms.common.pojo.vo.TransferFactoryTicketVO">
|
||||
SELECT tft."id",tft."no" AS "ticket_no",tft.create_by,tft.create_time,tft.update_time,tft.update_by
|
||||
SELECT tft."id",tf.id as "orderId",tft."no" AS "ticket_no",tft.create_by,tft.create_time,tft.update_time,tft.update_by
|
||||
,tft.doc_year,tft.mat_doc,tft.finish,tft.audit_state,tft.audit_by,tft.audit_time,tft.audit_msg,tf.*
|
||||
FROM wms_transfer_factory_ticket tft
|
||||
INNER JOIN wms_transfer_factory tf ON tft.order_id=tf."id"
|
||||
|
|
|
|||
Loading…
Reference in New Issue