lc/lc123/cloud/app/api/controller/WMSInvoiceQueryController.java

120 lines
6.7 KiB
Java
Raw Normal View History

package tqq9.lc123.cloud.app.api.controller;
import com.drew.lang.annotations.NotNull;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.openapi.common.custom.annotation.ApiController;
import kd.bos.openapi.common.custom.annotation.ApiGetMapping;
import kd.bos.openapi.common.custom.annotation.ApiParam;
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import tqq9.lc123.cloud.app.api.model.WMSInvoiceQueryModel;
import tqq9.lc123.cloud.app.api.utils.Constants;
/**
* WMS发票接口
*/
@ApiController(value = "WMSInvoiceQueryController", desc = "WMS发票查询接口自定义插件")
public class WMSInvoiceQueryController extends AbstractFormPlugin implements Plugin {
private final static Log logger = LogFactory.getLog(WMSInvoiceQueryController.class);
@ApiPostMapping(value = "/WMS_InvoiceQuery", desc = "WMS发票查询api接口")
public CustomApiResult<WMSInvoiceQueryModel> WMS_InvoiceQuery
2025-09-26 09:42:35 +00:00
(
@NotNull @ApiParam(value = "发运单号", required = true) String cDPCode,
@NotNull @ApiParam(value = "归属", required = true) String BelongTo
) {
WMSInvoiceQueryModel wmsInvoiceQueryModel = new WMSInvoiceQueryModel();
String code ="0";
String message ="成功";
WMSInvoiceQueryModel.Data data = new WMSInvoiceQueryModel.Data();
2025-09-26 09:42:35 +00:00
String billno = cDPCode;
2025-10-31 04:37:33 +00:00
String pdffileurl = null;
QFilter qFilter = new QFilter("billno", QCP.in, billno);
qFilter.and("billstatus", QCP.equals, "C");
DynamicObject sm_delivernotice = BusinessDataServiceHelper.loadSingle(Constants.SM_DELIVERNOTICE, qFilter.toArray());
if (sm_delivernotice != null) {
DynamicObjectCollection billentry = sm_delivernotice.getDynamicObjectCollection("billentry");//物料分录
String mainbillnumber = billentry.get(0).getString("mainbillnumber");//核心单据编号
DynamicObject sm_salorder = BusinessDataServiceHelper.loadSingle(Constants.SM_SALORDER, new QFilter[]{new QFilter("billno", QCP.equals, mainbillnumber).and("billentry.hasarbusbill", QCP.equals, true)});
if (sm_salorder != null) {
DynamicObject sim_original_bil = BusinessDataServiceHelper.loadSingle(Constants.SIM_ORIGINAL_BILL, new QFilter[]{new QFilter("sim_original_bill_item.corebillno", QCP.equals, mainbillnumber)});
if (sim_original_bil != null) {
String invoiceno = sim_original_bil.getString("invoiceno");
DynamicObject sim_vatinvoice = BusinessDataServiceHelper.loadSingle("sim_vatinvoice", new QFilter[]{new QFilter("invoiceno", QCP.equals, invoiceno)});
2025-10-31 04:37:33 +00:00
if (sim_vatinvoice != null && StringUtils.isNotBlank(sim_vatinvoice.getString("pdffileurl"))) {
pdffileurl = sim_vatinvoice.getString("pdffileurl");
}else{
code ="-1";
message ="根据DP单号:"+cDPCode+",未找到发票查询信息";
}
}else{
code ="-1";
message ="根据DP单号:"+cDPCode+",未找到开票申请单";
}
}else{
code ="-1";
message ="根据DP单号:"+cDPCode+",未找到开票申请单";
}
}
2025-10-31 04:37:33 +00:00
data.setSalesInvoiceUrl(pdffileurl);
data.setSalesOrderCode(billno);
wmsInvoiceQueryModel.setCode(code);
wmsInvoiceQueryModel.setMessage(message);
wmsInvoiceQueryModel.setData(data);
return CustomApiResult.success(wmsInvoiceQueryModel);
}
@ApiGetMapping(value = "/WMS_InvoiceQuery_SH", desc = "WMS发票查询api接口_SH")
public CustomApiResult<WMSInvoiceQueryModel> WMS_InvoiceQuery_SH
(@NotNull @ApiParam(value = "入参", required = true) String salesOrderCode) {
WMSInvoiceQueryModel wmsInvoiceQueryModel = new WMSInvoiceQueryModel();
String code ="0";
String message ="成功";
WMSInvoiceQueryModel.Data data = new WMSInvoiceQueryModel.Data();
String billno = salesOrderCode;
2025-10-31 04:37:33 +00:00
String pdffileurl = null;
QFilter qFilter = new QFilter("billno", QCP.in, billno);
qFilter.and("billstatus", QCP.equals, "C");
DynamicObject sm_delivernotice = BusinessDataServiceHelper.loadSingle(Constants.SM_DELIVERNOTICE, qFilter.toArray());
if (sm_delivernotice != null) {
DynamicObjectCollection billentry = sm_delivernotice.getDynamicObjectCollection("billentry");//物料分录
String mainbillnumber = billentry.get(0).getString("mainbillnumber");//核心单据编号
DynamicObject sm_salorder = BusinessDataServiceHelper.loadSingle(Constants.SM_SALORDER, new QFilter[]{new QFilter("billno", QCP.equals, mainbillnumber).and("billentry.hasarbusbill", QCP.equals, true)});
if (sm_salorder != null) {
DynamicObject sim_original_bil = BusinessDataServiceHelper.loadSingle(Constants.SIM_ORIGINAL_BILL, new QFilter[]{new QFilter("sim_original_bill_item.corebillno", QCP.equals, mainbillnumber)});
if (sim_original_bil != null) {
String invoiceno = sim_original_bil.getString("invoiceno");
DynamicObject sim_vatinvoice = BusinessDataServiceHelper.loadSingle("sim_vatinvoice", new QFilter[]{new QFilter("invoiceno", QCP.equals, invoiceno)});
2025-10-31 04:37:33 +00:00
if (sim_vatinvoice != null && StringUtils.isNotBlank(sim_vatinvoice.getString("pdffileurl"))) {
pdffileurl = sim_vatinvoice.getString("pdffileurl");
}else{
code ="-1";
message ="根据DP单号:"+salesOrderCode+",未找到发票查询信息";
}
}else{
code ="-1";
message ="根据DP单号:"+salesOrderCode+",未找到开票申请单";
}
}
}else{
code ="-1";
message ="根据DP单号:"+salesOrderCode+",未找到销售订单";
}
2025-10-31 04:37:33 +00:00
data.setSalesInvoiceUrl(pdffileurl);
data.setSalesOrderCode(billno);
wmsInvoiceQueryModel.setCode(code);
wmsInvoiceQueryModel.setMessage(message);
wmsInvoiceQueryModel.setData(data);
return CustomApiResult.success(wmsInvoiceQueryModel);
}
}