【商城接口】--销售单出库拦截
This commit is contained in:
parent
8ef8ef1aed
commit
876694c5bd
|
|
@ -0,0 +1,127 @@
|
|||
package tqq9.lc123.cloud.app.api.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.drew.lang.annotations.NotNull;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
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.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.util.StringUtils;
|
||||
import tqq9.lc123.cloud.app.api.utils.ApiResultExt;
|
||||
import tqq9.lc123.cloud.app.api.utils.Constants;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
/**
|
||||
* 发货通知单接口
|
||||
*/
|
||||
@ApiController(value = "SmDeliverNoticeController", desc = "发货通知单接口")
|
||||
public class SmDeliverNoticeController {
|
||||
|
||||
@ApiPostMapping(value = "/closeSmDeliverNotice", desc = "根据销售订单编号关闭发货通知单")
|
||||
public CustomApiResult<ApiResultExt> closeSmDeliverNotice(@NotNull @ApiParam(value = "销售订单编号", required = true) String orderBillNo) {
|
||||
//返回值初始化
|
||||
ApiResultExt resultExt = new ApiResultExt();
|
||||
List<ApiResultExt.ResultBean> results = new ArrayList<>();
|
||||
resultExt.setResult(results);
|
||||
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
|
||||
results.add(resultBean);
|
||||
JSONObject key = new JSONObject();
|
||||
key.put("billno", orderBillNo);
|
||||
resultBean.setKeys(key);
|
||||
ApiResultExt.Error error = new ApiResultExt.Error();
|
||||
resultBean.setErrors(error);
|
||||
ArrayList<String> rowmsg = new ArrayList<>();
|
||||
error.setRowMsg(rowmsg);
|
||||
String errormsg = null;
|
||||
resultBean.setBillIndex(0);
|
||||
resultBean.setKeys(key);
|
||||
resultBean.setNumber(orderBillNo);
|
||||
resultBean.setType(Constants.TYPE_CLOSE);
|
||||
|
||||
// 根据销售订单编码查询发货通知单
|
||||
DynamicObject smDeliverNotice = BusinessDataServiceHelper.loadSingle(Constants.SM_DELIVERNOTICE,
|
||||
"id,billno,org,tqq9_isclose,tqq9_gldjh,tqq9_ck",
|
||||
new QFilter[]{
|
||||
new QFilter("tqq9_gldjh", QCP.equals, orderBillNo)
|
||||
});
|
||||
if (null == smDeliverNotice) {
|
||||
errormsg = "传入参数订单编号:" + orderBillNo + " 在金蝶系统中未查询到对应的发货通知单";
|
||||
ApiResultExt.errorRetrun(Constants.SM_DELIVERNOTICE, errormsg, error, resultExt);
|
||||
return CustomApiResult.success(resultExt);
|
||||
}
|
||||
// 是否关闭
|
||||
boolean tqq9_isclose = smDeliverNotice.getBoolean("tqq9_isclose");
|
||||
if (tqq9_isclose) {
|
||||
errormsg = "传入参数订单编号:" + orderBillNo + " 在金蝶系统中对应的发货通知单已关闭,无需再次关闭";
|
||||
ApiResultExt.errorRetrun(Constants.SM_DELIVERNOTICE, errormsg, error, resultExt);
|
||||
return CustomApiResult.success(resultExt);
|
||||
}
|
||||
// 关联查询下游单据
|
||||
Map<String, HashSet<Long>> targetBills = BFTrackerServiceHelper.findTargetBills(Constants.SM_DELIVERNOTICE,
|
||||
new Long[]{smDeliverNotice.getLong("id")});
|
||||
//下游存在系统进行提示不允许后续操作
|
||||
if (null != targetBills && !targetBills.isEmpty() && targetBills.containsKey("im_saloutbill")) {
|
||||
errormsg = "传入参数订单编号:" + orderBillNo + " 在金蝶系统中已生成下游出库单据,无法关闭";
|
||||
ApiResultExt.errorRetrun(Constants.SM_DELIVERNOTICE, errormsg, error, resultExt);
|
||||
return CustomApiResult.success(resultExt);
|
||||
}
|
||||
// 收货组织
|
||||
DynamicObject org = smDeliverNotice.getDynamicObject("org");
|
||||
if (null != org) {
|
||||
// 返回通知单编码
|
||||
String billNo = smDeliverNotice.getString("billno");
|
||||
String entityName;
|
||||
String label = "tqq9_isclose";
|
||||
String closeMessage = "";
|
||||
String number = org.getString("number");
|
||||
if ("SHLC".equals(number)) {
|
||||
String warehouseCode = null;
|
||||
DynamicObject warehouse = smDeliverNotice.getDynamicObject("tqq9_ck");
|
||||
if (null != warehouse) {
|
||||
warehouseCode = warehouse.getString("number");
|
||||
}
|
||||
String orderType = "PTCK";
|
||||
entityName = "WMS-SH-发货通知单取消";
|
||||
closeMessage = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, Constants.SM_DELIVERNOTICE, entityName, label);
|
||||
} else if ("BJLC".equals(number)) {
|
||||
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||
entityName = "WMS-BJ-发货通知单取消";
|
||||
closeMessage = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, BJ_URL, Constants.SM_DELIVERNOTICE, entityName, label);
|
||||
|
||||
} else if ("GZLC".equals(number)) {
|
||||
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
|
||||
entityName = "WMS-GZ-发货通知单取消";
|
||||
closeMessage = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, Constants.SM_DELIVERNOTICE, entityName, label);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(closeMessage) && closeMessage.contains("关闭成功")) {
|
||||
cloneOperation(smDeliverNotice, "发货通知单", Constants.SM_SALORDER);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(closeMessage)) {
|
||||
errormsg = "传入参数订单编号:" + orderBillNo + " 关闭发货通知单失败,失败信息:" + closeMessage;
|
||||
ApiResultExt.errorRetrun(Constants.SM_DELIVERNOTICE, errormsg, error, resultExt);
|
||||
return CustomApiResult.success(resultExt);
|
||||
}
|
||||
}
|
||||
//回传成功
|
||||
int failCount = 0;//失败数量
|
||||
int successCount = 1;//成功数量
|
||||
resultExt.setFailCount(failCount);
|
||||
resultExt.setSuccessCount(successCount);
|
||||
resultExt.setResult(results);
|
||||
return CustomApiResult.success(resultExt);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue