获取附件10/10
This commit is contained in:
		
							parent
							
								
									b55a46a8c2
								
							
						
					
					
						commit
						64f0f40f4d
					
				|  | @ -0,0 +1,115 @@ | |||
| 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.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.datamodel.IDataModel; | ||||
| 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 ZczPostApi extends AbstractBillPlugIn implements Plugin { | ||||
|     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"); | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs e) { | ||||
|         super.afterDoOperation(e); | ||||
|         String operateKey = e.getOperateKey(); | ||||
|         IDataModel model = this.getModel(); | ||||
|         DynamicObject dataEntity = model.getDataEntity(); | ||||
|         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"); | ||||
|         if ("audit".equals(operateKey)) { | ||||
|             DynamicObject file = BusinessDataServiceHelper.loadSingle("tqq9_registration", "id,tqq9_attachmentpanelbj,tqq9_supplier.number,tqq9_supplier.tqq9_prolicense,tqq9_entry,tqq9_entry.tqq9_e_supplier", | ||||
|                     new QFilter[]{new QFilter("number", QFilter.equals, number)}); | ||||
|             DynamicObjectCollection tqq9_entry = file.getDynamicObjectCollection("tqq9_entry"); | ||||
|             //分录 | ||||
|             ArrayList<HashMap<String, String>> list = new ArrayList<>(); | ||||
|             for (DynamicObject entry : tqq9_entry) { | ||||
|                 DynamicObject tqq9_e_supplier = entry.getDynamicObject("tqq9_e_supplier"); | ||||
|                 if (tqq9_e_supplier != null) { | ||||
|                     HashMap<String, String> scsmap = new HashMap<>(); | ||||
|                     String number2 = tqq9_e_supplier.getString("number"); | ||||
|                     DynamicObject file2 = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", "id,number,tqq9_prolicense", | ||||
|                             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); | ||||
|                     scsmap.put("IsAgent", "0"); | ||||
|                     list.add(scsmap); | ||||
|                 } | ||||
|             } | ||||
|             //北京 | ||||
|             //获取单据中附件面板信息 | ||||
|             List<Map<String, Object>> bj_atts = AttachmentServiceHelper.getAttachments("tqq9_registration", file.getPkValue().toString(), "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", file.getPkValue().toString(), "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", list);//成产商 | ||||
|             String bjjsonBody = JSON.toJSONString(bj_map); | ||||
| 
 | ||||
|             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", list); | ||||
|             String gzjsonBody = JSON.toJSONString(bj_map); | ||||
|             //北京 | ||||
|             try { | ||||
|                 String s1 = HttpRequestUtils.postJson(BJ_URL + "/api/BA/Registration", bjjsonBody, null); | ||||
|             } catch (IOException ex) { | ||||
|                 throw new RuntimeException(ex); | ||||
|             } | ||||
|             //广州 | ||||
|             try { | ||||
|                 String s2 = HttpRequestUtils.postJson(GZ_URL + "/api/BA/Registration", gzjsonBody, null); | ||||
|             } catch (IOException ex) { | ||||
|                 throw new RuntimeException(ex); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue