78 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Java
		
	
	
	
		
		
			
		
	
	
			78 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Java
		
	
	
	
| 
								 | 
							
								package tqq9.lc123.cloud.app.plugin.operate.sys;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								import com.alibaba.fastjson.JSON;
							 | 
						|||
| 
								 | 
							
								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;
							 | 
						|||
| 
								 | 
							
								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 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 {
							 | 
						|||
| 
								 | 
							
								                    String s1 = HttpRequestUtils.postJson(BJ_URL + "/api/BA/Manufacturer", jsonBody, headMap);
							 | 
						|||
| 
								 | 
							
								                    logger.info("北京生产商同步结果:" + s1);
							 | 
						|||
| 
								 | 
							
								                } catch (IOException ex) {
							 | 
						|||
| 
								 | 
							
								                    throw new RuntimeException(ex);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                //广州
							 | 
						|||
| 
								 | 
							
								                try {
							 | 
						|||
| 
								 | 
							
								                    String s2 = HttpRequestUtils.postJson(GZ_URL + "/api/BA/Manufacturer", jsonBody, headMap);
							 | 
						|||
| 
								 | 
							
								                    logger.info("广州生产商同步结果:" + s2);
							 | 
						|||
| 
								 | 
							
								                } catch (IOException ex) {
							 | 
						|||
| 
								 | 
							
								                    throw new RuntimeException(ex);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |