2025-09-20 09:51:33 +00:00
|
|
|
|
package tqq9.lc123.cloud.app.api.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.drew.lang.annotations.NotNull;
|
2025-10-04 03:50:49 +00:00
|
|
|
|
import com.google.gson.Gson;
|
2025-09-20 09:51:33 +00:00
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
|
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.bos.servicehelper.operation.SaveServiceHelper;
|
2025-10-04 03:50:49 +00:00
|
|
|
|
import tqq9.lc123.cloud.app.api.model.WMSXmlReturn;
|
2025-09-20 09:51:33 +00:00
|
|
|
|
import tqq9.lc123.cloud.app.api.utils.ApiResultExt;
|
|
|
|
|
|
import tqq9.lc123.cloud.app.api.utils.Constants;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.List;
|
2025-10-04 03:50:49 +00:00
|
|
|
|
import java.util.Map;
|
2025-09-20 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* WMS物流信息同步接口
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiController(value = "WMSLogiSyncController", desc = "WMS物流信息同步接口,自定义插件")
|
|
|
|
|
|
|
|
|
|
|
|
public class WMSLogiSyncController {
|
|
|
|
|
|
private final static Log logger = LogFactory.getLog(WMSLogiSyncController.class);
|
2025-09-25 07:56:49 +00:00
|
|
|
|
@ApiPostMapping(value = "/WMS_LogiSync", desc = "WMS物流信息同步api插件")
|
|
|
|
|
|
public CustomApiResult<ApiResultExt> WMS_LogiSync
|
2025-09-26 09:42:35 +00:00
|
|
|
|
(
|
|
|
|
|
|
@NotNull @ApiParam(value = "发运单号", required = true) String cDPCode,
|
|
|
|
|
|
@NotNull @ApiParam(value = "快递公司", required = true) String ExpressCompany,
|
|
|
|
|
|
@NotNull @ApiParam(value = "快递单号", required = true) String cWayBillCode
|
|
|
|
|
|
) {
|
2025-09-20 09:51:33 +00:00
|
|
|
|
ApiResultExt resultExt = new ApiResultExt();
|
2025-09-25 07:56:49 +00:00
|
|
|
|
List<ApiResultExt.ResultBean> results = new ArrayList<>();
|
|
|
|
|
|
resultExt.setResult(results);
|
2025-09-26 09:42:35 +00:00
|
|
|
|
String billno = cDPCode;
|
2025-09-25 07:56:49 +00:00
|
|
|
|
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
|
|
|
|
|
|
results.add(resultBean);
|
2025-09-20 09:51:33 +00:00
|
|
|
|
JSONObject keys = new JSONObject();
|
|
|
|
|
|
keys.put("billno", billno);
|
2025-09-25 07:56:49 +00:00
|
|
|
|
resultBean.setKeys(keys);
|
|
|
|
|
|
ApiResultExt.Error error =new ApiResultExt.Error();
|
|
|
|
|
|
resultBean.setErrors(error);
|
|
|
|
|
|
ArrayList<String> rowmsg = new ArrayList<>();
|
|
|
|
|
|
error.setRowMsg(rowmsg);
|
|
|
|
|
|
String errorMsg=null;
|
2025-09-20 09:51:33 +00:00
|
|
|
|
resultBean.setBillIndex(0);
|
|
|
|
|
|
resultBean.setKeys(keys);
|
|
|
|
|
|
resultBean.setNumber(billno);
|
|
|
|
|
|
resultBean.setType(Constants.TYPE_UPDATE);
|
2025-09-25 07:56:49 +00:00
|
|
|
|
String entityType = Constants.IM_PURINBILL;
|
|
|
|
|
|
//必填项校验
|
|
|
|
|
|
if (ApiResultExt.validateRequired(billno, "String")) {
|
|
|
|
|
|
errorMsg="传入参数 cDPCode 为空";
|
|
|
|
|
|
resultExt = ApiResultExt.errorRetrun(entityType, errorMsg, error, resultExt);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ApiResultExt.validateRequired(ExpressCompany, "String")) {
|
|
|
|
|
|
errorMsg="传入参数 ExpressCompany 为空";
|
|
|
|
|
|
|
|
|
|
|
|
resultExt = ApiResultExt.errorRetrun(entityType, errorMsg, error, resultExt);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ApiResultExt.validateRequired(cWayBillCode, "String")) {
|
|
|
|
|
|
errorMsg="传入参数 cWayBillCode 为空";
|
|
|
|
|
|
resultExt = ApiResultExt.errorRetrun(entityType, errorMsg, error, resultExt);
|
|
|
|
|
|
}
|
|
|
|
|
|
rowmsg = resultExt.getResult().get(0).getErrors().getRowMsg();
|
|
|
|
|
|
if (!rowmsg.isEmpty()) {
|
|
|
|
|
|
return CustomApiResult.success(resultExt);
|
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
|
|
|
String id= sm_delivernotice.getString("id");//发货通知单id
|
2025-09-20 09:51:33 +00:00
|
|
|
|
resultBean.setId(id);
|
|
|
|
|
|
resultBean.setBillStatus(true);
|
2025-09-25 07:56:49 +00:00
|
|
|
|
DynamicObjectCollection tqq9_logisticsinfo = sm_delivernotice.getDynamicObjectCollection("tqq9_logisticsinfo");
|
|
|
|
|
|
DynamicObject dynamicObject = tqq9_logisticsinfo.addNew();
|
|
|
|
|
|
dynamicObject.set("tqq9_carrier",ExpressCompany);
|
|
|
|
|
|
dynamicObject.set("tqq9_shipmentid",cWayBillCode);
|
|
|
|
|
|
SaveServiceHelper.save(new DynamicObject[]{sm_delivernotice});
|
2025-09-20 09:51:33 +00:00
|
|
|
|
} else {
|
2025-09-25 07:56:49 +00:00
|
|
|
|
rowmsg.add("根据传入发运单号未找到对应的发货通知单");
|
|
|
|
|
|
resultExt = ApiResultExt.errorRetrun(entityType, errorMsg, error, resultExt);
|
|
|
|
|
|
return CustomApiResult.success(resultExt);
|
2025-09-20 09:51:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
resultBean.setErrors(error);
|
2025-09-25 07:56:49 +00:00
|
|
|
|
// results.add(resultBean);
|
|
|
|
|
|
int failCount = 0;//失败数量
|
|
|
|
|
|
int successCount = 1;//成功数量
|
2025-09-20 09:51:33 +00:00
|
|
|
|
resultExt.setFailCount(failCount);
|
|
|
|
|
|
resultExt.setSuccessCount(successCount);
|
|
|
|
|
|
resultExt.setResult(results);
|
|
|
|
|
|
return CustomApiResult.success(resultExt);
|
|
|
|
|
|
}
|
2025-10-04 03:50:49 +00:00
|
|
|
|
|
|
|
|
|
|
@ApiPostMapping(value = "/WMS_LogiSync_SH", desc = "WMS物流信息同步api插件_SH")
|
|
|
|
|
|
public CustomApiResult<WMSXmlReturn> WMS_LogiSync_SH
|
|
|
|
|
|
(@NotNull @ApiParam(value = "入参", required = true) Map<String, Object> dataMap) {
|
|
|
|
|
|
//返回值初始化
|
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
|
JSONObject data = gson.fromJson(dataMap.toString(), JSONObject.class);
|
|
|
|
|
|
JSONObject request = data.getJSONObject("request");
|
|
|
|
|
|
String billno = request.getString("orderCode");//单据编号
|
|
|
|
|
|
String logisticsName = request.getString("logisticsName");//物流公司名称
|
|
|
|
|
|
String expressCode = request.getString("expressCode");//物流单据编号
|
|
|
|
|
|
|
|
|
|
|
|
WMSXmlReturn wmsXmlReturn = new WMSXmlReturn();
|
|
|
|
|
|
WMSXmlReturn.Response response = new WMSXmlReturn.Response();
|
|
|
|
|
|
wmsXmlReturn.setResponse(response);
|
|
|
|
|
|
response.setCode("0");
|
|
|
|
|
|
response.setFlag("success");
|
|
|
|
|
|
response.setMessage("成功");
|
|
|
|
|
|
StringBuilder errormsg = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
//必填项校验
|
|
|
|
|
|
if (ApiResultExt.validateRequired(billno, "String")) {
|
2025-10-09 09:05:55 +00:00
|
|
|
|
errormsg = errormsg.append(";").append("传入参数 orderCode 为空");
|
2025-10-04 03:50:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (ApiResultExt.validateRequired(logisticsName, "String")) {
|
2025-10-09 09:05:55 +00:00
|
|
|
|
errormsg = errormsg.append(";").append("传入参数 logisticsName 为空");
|
2025-10-04 03:50:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (ApiResultExt.validateRequired(expressCode, "String")) {
|
2025-10-09 09:05:55 +00:00
|
|
|
|
errormsg = errormsg.append(";").append("传入参数 expressCode 为空");
|
2025-10-04 03:50:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (errormsg.length() > 0) {
|
|
|
|
|
|
response.setMessage(errormsg.substring(1));
|
|
|
|
|
|
response.setCode("-1");
|
|
|
|
|
|
response.setFlag("failure");
|
|
|
|
|
|
return CustomApiResult.success(wmsXmlReturn);
|
|
|
|
|
|
}
|
|
|
|
|
|
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 tqq9_logisticsinfo = sm_delivernotice.getDynamicObjectCollection("tqq9_logisticsinfo");
|
|
|
|
|
|
DynamicObject dynamicObject = tqq9_logisticsinfo.addNew();
|
|
|
|
|
|
dynamicObject.set("tqq9_carrier",logisticsName);
|
|
|
|
|
|
dynamicObject.set("tqq9_shipmentid",expressCode);
|
|
|
|
|
|
SaveServiceHelper.save(new DynamicObject[]{sm_delivernotice});
|
|
|
|
|
|
} else {
|
2025-10-09 09:05:55 +00:00
|
|
|
|
errormsg = errormsg.append(";").append("根据传入发运单号未找到对应的发货通知单");
|
2025-10-04 03:50:49 +00:00
|
|
|
|
response.setMessage(errormsg.substring(1));
|
|
|
|
|
|
response.setCode("-1");
|
|
|
|
|
|
response.setFlag("failure");
|
|
|
|
|
|
return CustomApiResult.success(wmsXmlReturn);
|
|
|
|
|
|
}
|
|
|
|
|
|
return CustomApiResult.success(wmsXmlReturn);
|
|
|
|
|
|
}
|
2025-09-20 09:51:33 +00:00
|
|
|
|
}
|