2025-10-29 08:01:20 +00:00
|
|
|
|
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
2025-11-12 06:17:18 +00:00
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
2025-10-29 08:01:20 +00:00
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
|
|
|
import kd.bos.logging.Log;
|
|
|
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
2025-11-12 06:17:18 +00:00
|
|
|
|
import kd.bos.util.StringUtils;
|
|
|
|
|
|
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
2025-10-29 08:01:20 +00:00
|
|
|
|
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;
|
2025-11-12 06:17:18 +00:00
|
|
|
|
|
2025-10-29 08:01:20 +00:00
|
|
|
|
//北广生产商同步
|
|
|
|
|
|
public class BGScsOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
|
|
|
private final static Log logger = LogFactory.getLog(BGScsOpPlugin.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
|
|
|
super.afterExecuteOperationTransaction(e);
|
|
|
|
|
|
DynamicObject[] dataEntities1 = e.getDataEntities();
|
|
|
|
|
|
if (null != dataEntities1 && dataEntities1.length > 0) {
|
|
|
|
|
|
for (DynamicObject dataEntity : dataEntities1) {
|
|
|
|
|
|
DynamicObject BJURL = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, "BJ_POSTURL")});
|
|
|
|
|
|
String BJ_URL = 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");
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> body = new HashMap<>();
|
|
|
|
|
|
List<String> fj = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//获取单据信息,并查询单据中的附件字段
|
|
|
|
|
|
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getLong("id"), "tqq9_proxyandfactory");
|
|
|
|
|
|
String number = dataEntity.getString("number");
|
|
|
|
|
|
//获取单据中附件面板信息
|
|
|
|
|
|
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("tqq9_proxyandfactory", dataEntity.getPkValue(), "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 = dataEntity.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<>();
|
|
|
|
|
|
logger.info("北广生产商同步body:" + jsonBody);
|
|
|
|
|
|
try {
|
2025-11-12 06:17:18 +00:00
|
|
|
|
String result = HttpRequestUtils.postJson(BJ_URL + "/api/BA/Manufacturer", jsonBody, headMap);
|
|
|
|
|
|
if (StringUtils.isNotEmpty(result)) {
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
JsonNode rootNode = objectMapper.readTree(result);
|
|
|
|
|
|
if (null != rootNode) {
|
|
|
|
|
|
String code = String.valueOf(rootNode.get("code"));
|
|
|
|
|
|
LCLogServiceImpl lcLogService = new LCLogServiceImpl();
|
|
|
|
|
|
lcLogService.savelog("北京生产商同步", BJ_URL+ "/api/BA/Manufacturer", true, code.equals("0"), jsonBody, result);
|
|
|
|
|
|
lcLogService.isSuccess("tqq9_proxyandfactory", number, "number", "tqq9_pushw", code.equals("0"));
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("北京生产商同步结果:" + result);
|
|
|
|
|
|
}
|
2025-10-29 08:01:20 +00:00
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
throw new RuntimeException(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//广州
|
|
|
|
|
|
try {
|
2025-11-12 06:17:18 +00:00
|
|
|
|
String result = HttpRequestUtils.postJson(GZ_URL + "/api/BA/Manufacturer", jsonBody, headMap);
|
|
|
|
|
|
if (StringUtils.isNotEmpty(result)) {
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
JsonNode rootNode = objectMapper.readTree(result);
|
|
|
|
|
|
if (null != rootNode) {
|
|
|
|
|
|
String code = String.valueOf(rootNode.get("code"));
|
|
|
|
|
|
LCLogServiceImpl lcLogService = new LCLogServiceImpl();
|
|
|
|
|
|
lcLogService.savelog("广州生产商同步", GZ_URL+ "/api/BA/Manufacturer", true, code.equals("0"), jsonBody, result);
|
|
|
|
|
|
lcLogService.isSuccess("tqq9_proxyandfactory", number, "number", "tqq9_pushw", code.equals("0"));
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("广州生产商同步结果:" + result);
|
|
|
|
|
|
}
|
2025-10-29 08:01:20 +00:00
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
throw new RuntimeException(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|