65 lines
2.8 KiB
Java
65 lines
2.8 KiB
Java
|
|
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
||
|
|
|
||
|
|
|
||
|
|
import com.alibaba.fastjson.JSON;
|
||
|
|
import kd.bos.bill.AbstractBillPlugIn;
|
||
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
||
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||
|
|
import kd.bos.orm.query.QCP;
|
||
|
|
import kd.bos.orm.query.QFilter;
|
||
|
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||
|
|
import kd.sdk.plugin.Plugin;
|
||
|
|
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
||
|
|
|
||
|
|
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
public class ScsPostApi extends AbstractBillPlugIn implements Plugin {
|
||
|
|
@Override
|
||
|
|
public void afterDoOperation(AfterDoOperationEventArgs eventArgs) {
|
||
|
|
super.afterDoOperation(eventArgs);
|
||
|
|
DynamicObject BJURL = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||
|
|
new QFilter[]{new QFilter("number", QCP.equals, "BJ_POSTURL")});
|
||
|
|
String BJ_URL = (String) BJURL.getString("name");
|
||
|
|
DynamicObject GZURL = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||
|
|
new QFilter[]{new QFilter("number", QCP.equals, "GZ_POSTURL")});
|
||
|
|
String GZ_URL = GZURL.getString("name");
|
||
|
|
|
||
|
|
String operateKey = eventArgs.getOperateKey();
|
||
|
|
if ("audit".equals(operateKey)){
|
||
|
|
HashMap<String, Object> body = new HashMap<>();
|
||
|
|
List<String> fj = new ArrayList<>();
|
||
|
|
String number = (String) this.getModel().getValue("number");
|
||
|
|
//获取单据信息,并查询单据中的附件字段
|
||
|
|
DynamicObject file = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", "*",
|
||
|
|
new QFilter[]{new QFilter("number", QFilter.equals, number)});
|
||
|
|
//获取单据中附件面板信息
|
||
|
|
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("tqq9_proxyandfactory", file.getPkValue().toString(), "tqq9_attachmentpanelap");
|
||
|
|
for (Map<String, Object> att : atts) {
|
||
|
|
String url = (String) att.get("url");
|
||
|
|
fj.add(url);
|
||
|
|
}
|
||
|
|
String[] collectArray = fj.toArray(new String[0]);
|
||
|
|
String fname = file.getString("name");
|
||
|
|
body.put("MFCode",number);
|
||
|
|
body.put("MFName",fname);
|
||
|
|
body.put("lstImageUrls",collectArray);
|
||
|
|
String jsonBody = JSON.toJSONString(body);
|
||
|
|
HashMap<String, String> headMap = new HashMap<>();
|
||
|
|
try {
|
||
|
|
String s1 = HttpRequestUtils.postJson(BJ_URL+"/api/BA/Manufacturer", jsonBody, headMap);
|
||
|
|
String s2 = HttpRequestUtils.postJson(GZ_URL+"/api/BA/Manufacturer", jsonBody, headMap);
|
||
|
|
} catch (IOException e) {
|
||
|
|
throw new RuntimeException(e);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|