141 lines
6.8 KiB
Java
141 lines
6.8 KiB
Java
|
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
|||
|
|
|||
|
import com.alibaba.fastjson.JSON;
|
|||
|
import kd.bos.dataentity.entity.DynamicObject;
|
|||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|||
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
|||
|
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;
|
|||
|
import kd.bos.util.StringUtils;
|
|||
|
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 BGZczOpPlugin extends AbstractOperationServicePlugIn {
|
|||
|
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");
|
|||
|
DynamicObject WMSURL = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|||
|
new QFilter[]{new QFilter("number", QCP.equals, "Ttx_MainURL")});
|
|||
|
String WMS_URL = WMSURL.getString("name");
|
|||
|
|
|||
|
private final static Log logger = LogFactory.getLog(BGZczOpPlugin.class);
|
|||
|
@Override
|
|||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
|||
|
super.onPreparePropertys(e);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|||
|
super.afterExecuteOperationTransaction(e);
|
|||
|
DynamicObject[] dataEntities1 = e.getDataEntities();
|
|||
|
if (null != dataEntities1 && dataEntities1.length > 0) {
|
|||
|
for (DynamicObject dataEntity : dataEntities1) {
|
|||
|
HashMap<String, Object> bj_map = new HashMap<>();
|
|||
|
HashMap<String, Object> gz_map = new HashMap<>();
|
|||
|
List<String> bj = new ArrayList<>();
|
|||
|
List<String> gz = new ArrayList<>();
|
|||
|
|
|||
|
String number = dataEntity.getString("number");
|
|||
|
dataEntity=BusinessDataServiceHelper.loadSingle(dataEntity.getLong("id"),"tqq9_registration");
|
|||
|
|
|||
|
DynamicObjectCollection tqq9_entry = dataEntity.getDynamicObjectCollection("tqq9_entry");
|
|||
|
//分录
|
|||
|
ArrayList<HashMap<String, String>> bglist = new ArrayList<>();
|
|||
|
for (DynamicObject entry : tqq9_entry) {
|
|||
|
DynamicObject tqq9_e_supplier = entry.getDynamicObject("tqq9_e_supplier");
|
|||
|
if (tqq9_e_supplier != null) {
|
|||
|
//北广map
|
|||
|
HashMap<String, String> scsmap = new HashMap<>();
|
|||
|
|
|||
|
String number2 = tqq9_e_supplier.getString("number");
|
|||
|
DynamicObject file2 = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", "id,number,name,tqq9_prolicense,tqq9_type",
|
|||
|
new QFilter[]{new QFilter("number", QFilter.equals, number2)});
|
|||
|
String MFCode = file2.getString("number");
|
|||
|
String ProLicenceCode = file2.getString("tqq9_prolicense");
|
|||
|
scsmap.put("MFCode", MFCode);
|
|||
|
scsmap.put("ProLicenceCode", ProLicenceCode);
|
|||
|
String tqq9_type = file2.getString("tqq9_type");//厂商类型
|
|||
|
if (StringUtils.isNotEmpty(tqq9_type) && tqq9_type.contains("B")) {
|
|||
|
scsmap.put("isAgent", "1");//代理商
|
|||
|
} else {
|
|||
|
scsmap.put("isAgent", "0");
|
|||
|
}
|
|||
|
bglist.add(scsmap);
|
|||
|
}
|
|||
|
}
|
|||
|
//123564
|
|||
|
//北京
|
|||
|
//获取单据中附件面板信息
|
|||
|
List<Map<String, Object>> bj_atts = AttachmentServiceHelper.getAttachments("tqq9_registration", dataEntity.getPkValue(), "tqq9_attachmentpanelbj");
|
|||
|
for (Map<String, Object> att : bj_atts) {
|
|||
|
String url = (String) att.get("url");
|
|||
|
bj.add(url);
|
|||
|
}
|
|||
|
String[] bjcollect = bj.toArray(new String[0]);
|
|||
|
//广州
|
|||
|
//获取单据中附件面板信息
|
|||
|
List<Map<String, Object>> gz_atts = AttachmentServiceHelper.getAttachments("tqq9_registration", dataEntity.getPkValue(), "tqq9_attachmentpanelgz1");
|
|||
|
for (Map<String, Object> att : gz_atts) {
|
|||
|
String url = (String) att.get("url");
|
|||
|
gz.add(url);
|
|||
|
}
|
|||
|
String[] gzcollect = gz.toArray(new String[0]);
|
|||
|
//post请求body
|
|||
|
String dEndDate = dataEntity.getString("tqq9_enddate");//有效期至
|
|||
|
String cRemark = dataEntity.getString("tqq9_remark");//备注
|
|||
|
String IsImportation = dataEntity.getString("tqq9_type").equals("A") ? "1" : "0";//是否进口
|
|||
|
bj_map.put("cRegNo", number);
|
|||
|
bj_map.put("dEndDate", dEndDate);
|
|||
|
bj_map.put("cRemark", cRemark);
|
|||
|
bj_map.put("lstImageUrls", bjcollect);
|
|||
|
bj_map.put("IsImportation", IsImportation);
|
|||
|
bj_map.put("lstManufacturer", bglist);//成产商
|
|||
|
String bjjsonBody = JSON.toJSONString(bj_map);
|
|||
|
logger.info("北京注册证body:" + bjjsonBody);
|
|||
|
|
|||
|
gz_map.put("cRegNo", number);
|
|||
|
gz_map.put("dEndDate", dEndDate);
|
|||
|
gz_map.put("cRemark", cRemark);
|
|||
|
gz_map.put("lstImageUrls", gzcollect);
|
|||
|
gz_map.put("IsImportation", IsImportation);
|
|||
|
gz_map.put("lstManufacturer", bglist);
|
|||
|
String gzjsonBody = JSON.toJSONString(gz_map);
|
|||
|
logger.info("广州注册证body:" + gzjsonBody);
|
|||
|
//北京
|
|||
|
try {
|
|||
|
String s1 = HttpRequestUtils.postJson(BJ_URL + "/api/BA/Registration", bjjsonBody, null);
|
|||
|
logger.info("北京注册证同步结果:" + s1);
|
|||
|
} catch (IOException ex) {
|
|||
|
throw new RuntimeException(ex);
|
|||
|
}
|
|||
|
//广州
|
|||
|
try {
|
|||
|
String s2 = HttpRequestUtils.postJson(GZ_URL + "/api/BA/Registration", gzjsonBody, null);
|
|||
|
logger.info("广州注册证同步结果:" + s2);
|
|||
|
} catch (IOException ex) {
|
|||
|
throw new RuntimeException(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|