66 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			3.5 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.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;
 | ||
| 
 | ||
| import java.util.ArrayList;
 | ||
| import java.util.List;
 | ||
| 
 | ||
| /**
 | ||
|  * 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();
 | ||
|         List<WMSInvoiceQueryModel.ResultBean> result =  new ArrayList<>();
 | ||
|         WMSInvoiceQueryModel.ResultBean resultBean = new WMSInvoiceQueryModel.ResultBean();
 | ||
|         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");
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         resultBean.setInvoiceUrl(fileurl);
 | ||
|         result.add(resultBean);
 | ||
|         wmsInvoiceQueryModel.setResult(result);
 | ||
|         return CustomApiResult.success(wmsInvoiceQueryModel);
 | ||
|     }
 | ||
| } |