120 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Java
		
	
	
	
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
 | 
						||
            (
 | 
						||
                    @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();
 | 
						||
        String billno = cDPCode;
 | 
						||
        String fileurl = 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)});
 | 
						||
                    if (sim_vatinvoice != null && StringUtils.isNotBlank(sim_vatinvoice.getString("fileurl"))) {
 | 
						||
                        fileurl = sim_vatinvoice.getString("fileurl");
 | 
						||
                    }else{
 | 
						||
                        code ="-1";
 | 
						||
                        message ="根据DP单号:"+cDPCode+",未找到发票查询信息";
 | 
						||
                    }
 | 
						||
                }else{
 | 
						||
                    code ="-1";
 | 
						||
                    message ="根据DP单号:"+cDPCode+",未找到开票申请单";
 | 
						||
                }
 | 
						||
            }else{
 | 
						||
                code ="-1";
 | 
						||
                message ="根据DP单号:"+cDPCode+",未找到开票申请单";
 | 
						||
            }
 | 
						||
        }
 | 
						||
        data.setSalesInvoiceUrl(fileurl);
 | 
						||
        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;
 | 
						||
        String fileurl = 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)});
 | 
						||
                    if (sim_vatinvoice != null && StringUtils.isNotBlank(sim_vatinvoice.getString("fileurl"))) {
 | 
						||
                        fileurl = sim_vatinvoice.getString("fileurl");
 | 
						||
                    }else{
 | 
						||
                        code ="-1";
 | 
						||
                        message ="根据DP单号:"+salesOrderCode+",未找到发票查询信息";
 | 
						||
                    }
 | 
						||
                }else{
 | 
						||
                    code ="-1";
 | 
						||
                    message ="根据DP单号:"+salesOrderCode+",未找到开票申请单";
 | 
						||
                }
 | 
						||
            }
 | 
						||
        }else{
 | 
						||
            code ="-1";
 | 
						||
            message ="根据DP单号:"+salesOrderCode+",未找到销售订单";
 | 
						||
        }
 | 
						||
        data.setSalesInvoiceUrl(fileurl);
 | 
						||
        data.setSalesOrderCode(billno);
 | 
						||
        wmsInvoiceQueryModel.setCode(code);
 | 
						||
        wmsInvoiceQueryModel.setMessage(message);
 | 
						||
        wmsInvoiceQueryModel.setData(data);
 | 
						||
        return CustomApiResult.success(wmsInvoiceQueryModel);
 | 
						||
    }
 | 
						||
} |