获取附件10/13
This commit is contained in:
		
							parent
							
								
									3e71cda8eb
								
							
						
					
					
						commit
						5702895885
					
				|  | @ -18,7 +18,6 @@ public class ScsGetUPLPlugin extends AbstractBillPlugIn implements Plugin { | |||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs eventArgs) { | ||||
|         super.afterDoOperation(eventArgs); | ||||
|         HashMap<String, Object> map = new HashMap<>(); | ||||
|         List<String> fj = new ArrayList<>(); | ||||
|         String operateKey = eventArgs.getOperateKey(); | ||||
|         String number = (String) this.getModel().getValue("number"); | ||||
|  | @ -33,7 +32,7 @@ public class ScsGetUPLPlugin extends AbstractBillPlugIn implements Plugin { | |||
|                 fj.add(url); | ||||
|             } | ||||
|             String[] collectArray = fj.toArray(new String[0]); | ||||
|             this.getModel().setValue("tqq9_fjurl_tag", collectArray); | ||||
|             this.getModel().setValue("tqq9_fjurl_tag", collectArray.toString()); | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -5,6 +5,8 @@ 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.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.AttachmentServiceHelper; | ||||
|  | @ -20,6 +22,7 @@ import java.util.List; | |||
| import java.util.Map; | ||||
| 
 | ||||
| public class ScsPostApi extends AbstractBillPlugIn implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(ScsPostApi.class); | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs eventArgs) { | ||||
|         super.afterDoOperation(eventArgs); | ||||
|  | @ -29,8 +32,8 @@ public class ScsPostApi extends AbstractBillPlugIn implements Plugin { | |||
|         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<>(); | ||||
|  | @ -54,6 +57,7 @@ public class ScsPostApi extends AbstractBillPlugIn implements Plugin { | |||
|             try { | ||||
|                 String s1 = HttpRequestUtils.postJson(BJ_URL+"/api/BA/Manufacturer", jsonBody, headMap); | ||||
|                 String s2 = HttpRequestUtils.postJson(GZ_URL+"/api/BA/Manufacturer", jsonBody, headMap); | ||||
|                 logger.info("结果:"+s1); | ||||
|             } catch (IOException e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } | ||||
|  |  | |||
|  | @ -1,18 +1,22 @@ | |||
| package tqq9.lc123.cloud.app.plugin.operate.sys; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| 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.isc.util.script.feature.tool.string.Json2Xml; | ||||
| 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 org.json.XML; | ||||
| import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils; | ||||
| 
 | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
|  | @ -29,6 +33,9 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|     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"); | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs e) { | ||||
|  | @ -40,26 +47,31 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|         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<>(); | ||||
|             ArrayList<HashMap<String, String>> bglist = new ArrayList<>(); | ||||
|             ArrayList<HashMap<String, String>> wmslist = 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,tqq9_prolicense", | ||||
|                     DynamicObject file2 = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", "id,number,name,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); | ||||
|                     scsmap.put("isAgent", "Y"); | ||||
|                     bglist.add(scsmap); | ||||
|                 } | ||||
|             } | ||||
|             //北京 | ||||
|  | @ -78,7 +90,6 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|                 gz.add(url); | ||||
|             } | ||||
|             String[] gzcollect = gz.toArray(new String[0]); | ||||
| 
 | ||||
|             //post请求body | ||||
|             String dEndDate = dataEntity.getString("tqq9_enddate");//有效期至 | ||||
|             String cRemark = dataEntity.getString("tqq9_remark");//备注 | ||||
|  | @ -88,7 +99,7 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|             bj_map.put("cRemark", cRemark); | ||||
|             bj_map.put("lstImageUrls", bjcollect); | ||||
|             bj_map.put("IsImportation", IsImportation); | ||||
|             bj_map.put("lstManufacturer", list);//成产商 | ||||
|             bj_map.put("lstManufacturer", bglist);//成产商 | ||||
|             String bjjsonBody = JSON.toJSONString(bj_map); | ||||
| 
 | ||||
|             gz_map.put("cRegNo", number); | ||||
|  | @ -96,8 +107,9 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|             gz_map.put("cRemark", cRemark); | ||||
|             gz_map.put("lstImageUrls", gzcollect); | ||||
|             gz_map.put("IsImportation", IsImportation); | ||||
|             gz_map.put("lstManufacturer", list); | ||||
|             gz_map.put("lstManufacturer", bglist); | ||||
|             String gzjsonBody = JSON.toJSONString(bj_map); | ||||
| 
 | ||||
|             //北京 | ||||
|             try { | ||||
|                 String s1 = HttpRequestUtils.postJson(BJ_URL + "/api/BA/Registration", bjjsonBody, null); | ||||
|  | @ -110,6 +122,9 @@ public class ZczPostApi extends AbstractBillPlugIn implements Plugin { | |||
|             } catch (IOException ex) { | ||||
|                 throw new RuntimeException(ex); | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,183 @@ | |||
| package tqq9.lc123.cloud.app.plugin.operate.sys; | ||||
| 
 | ||||
| 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.text.SimpleDateFormat; | ||||
| import java.util.*; | ||||
| 
 | ||||
| /** | ||||
|  * 动态表单插件 | ||||
|  */ | ||||
| public class wmsZczPostApi 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"); | ||||
|     DynamicObject WMSURL = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name", | ||||
|             new QFilter[]{new QFilter("number", QCP.equals, "Ttx_MainURL")}); | ||||
|     String WMS_URL = WMSURL.getString("name"); | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs e) { | ||||
|         super.afterDoOperation(e); | ||||
|         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||||
|         String operateKey = e.getOperateKey(); | ||||
|         IDataModel model = this.getModel(); | ||||
| 
 | ||||
|         DynamicObject dataEntity = model.getDataEntity(); | ||||
|         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"); | ||||
| 
 | ||||
|             //获取厂商分录的信息 | ||||
|             Map<String, Object> manufactoryList = new HashMap<>(); | ||||
|             List<Map<String, String>> manufactoryArray = new ArrayList<>(); | ||||
|             for (DynamicObject entry : tqq9_entry) { | ||||
|                 DynamicObject tqq9_e_supplier = entry.getDynamicObject("tqq9_e_supplier"); | ||||
|                 if (tqq9_e_supplier != null) { | ||||
|                     HashMap<String, String> map = new HashMap<>(); | ||||
|                     String number2 = tqq9_e_supplier.getString("number"); | ||||
|                     DynamicObject file2 = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", "id,number,name,tqq9_prolicense", | ||||
|                             new QFilter[]{new QFilter("number", QFilter.equals, number2)}); | ||||
|                     String MFCode = file2.getString("number"); | ||||
|                     String name = file2.getString("name"); | ||||
|                     String ProLicenceCode = file2.getString("tqq9_prolicense"); | ||||
|                     map.put("manufactoryCode", MFCode); | ||||
|                     map.put("manufactoryName", name); | ||||
|                     map.put("proLicenceCode", ProLicenceCode); | ||||
|                     manufactoryArray.add(map); | ||||
|                 } | ||||
|             } | ||||
|             manufactoryList.put("manufactory", manufactoryArray); | ||||
|             //获取url路径信息 | ||||
|             List<Map<String, String>> urlPathsArray = new ArrayList<>(); | ||||
|             List<Map<String, Object>> wms_atts = AttachmentServiceHelper.getAttachments("tqq9_registration", file.getPkValue().toString(), "tqq9_attachmentpanelsh"); | ||||
|             for (Map<String, Object> att : wms_atts) { | ||||
|                 HashMap<String, String> map = new HashMap<>(); | ||||
|                 String url = (String) att.get("url"); | ||||
|                 map.put("urlPath", url); | ||||
|                 urlPathsArray.add(map); | ||||
|             } | ||||
|             Map<String, Object> urlPathList = new HashMap<>(); | ||||
|             urlPathList.put("urlPaths", urlPathsArray); | ||||
| 
 | ||||
| 
 | ||||
|             //开始封装body | ||||
|             //<actionType>add|update, 必填</actionType> | ||||
|             //	<regNo>注册证号, string (250) , 必填</regNo> | ||||
|             //	<imported>是否进口,必填,Y/N (默认为N) </imported > | ||||
|             //<productDate>有效期始, string (10) , YYYY-MM-DD</productDate> | ||||
|             //	<expireDate>有效期至, string (10) , YYYY-MM-DD , 必填</expireDate> | ||||
|             //	<threeLevelClass >三级分类, string(50)</threeLevelClass > | ||||
|             //	<status>是否有效, Y/N (默认为Y) </ status> | ||||
|             String tqq9_startdate = sdf.format(dataEntity.getDate("tqq9_startdate"));//有效期至 | ||||
|             String tqq9_enddate = sdf.format(dataEntity.getDate("tqq9_enddate"));//有效期至 | ||||
|             String cRemark = dataEntity.getString("tqq9_remark");//备注 | ||||
|             String modifytime = sdf.format(dataEntity.getDate("modifytime"));//修改时间 | ||||
|             String IsImportation = dataEntity.getString("tqq9_type").equals("A") ? "Y" : "N";//是否进口 | ||||
|             Map<String, Object> request = new HashMap<>(); | ||||
|             request.put("actionType", "update"); | ||||
|             request.put("regNo", number); | ||||
|             request.put("imported", IsImportation); | ||||
|             request.put("productDate", tqq9_startdate); | ||||
|             request.put("expireDate", tqq9_enddate); | ||||
|             //request.put("threeLevelClass", "【三类】口腔科器械(17)"); | ||||
|             request.put("status", "Y"); | ||||
|             request.put("updateTime", modifytime); | ||||
|             request.put("urlPathList", urlPathList); | ||||
|             request.put("manufactoryList", manufactoryList); | ||||
|             // 最终的外层Map | ||||
|             Map<String, Object> finalMap = new HashMap<>(); | ||||
|             finalMap.put("request", request); | ||||
|             StringBuilder xmlBuilder = new StringBuilder(); | ||||
|             xmlBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | ||||
|             buildXml(xmlBuilder, finalMap, 0); | ||||
|             System.out.println("xmlBuilder:"+xmlBuilder); | ||||
| 
 | ||||
|             HashMap<String, String> headMap = new HashMap<>(); | ||||
|             try { | ||||
|                 String s = HttpRequestUtils.postXml(WMS_URL+ "?method=registrationcertificate.create&v=2.0&format=xml&customerId=123", xmlBuilder.toString(), headMap); | ||||
|                 System.out.println(s); | ||||
|             } catch (IOException ex) { | ||||
|                 throw new RuntimeException(ex); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static void buildXml(StringBuilder xmlBuilder, Map<String, Object> map, int indent) { | ||||
|         String indentStr = createIndent(indent); | ||||
| 
 | ||||
|         for (Map.Entry<String, Object> entry : map.entrySet()) { | ||||
|             String key = entry.getKey(); | ||||
|             Object value = entry.getValue(); | ||||
| 
 | ||||
|             if (value instanceof Map) { | ||||
|                 // 处理嵌套Map | ||||
|                 xmlBuilder.append(indentStr).append("<").append(key).append(">\n"); | ||||
|                 buildXml(xmlBuilder, (Map<String, Object>) value, indent + 1); | ||||
|                 xmlBuilder.append(indentStr).append("</").append(key).append(">\n"); | ||||
|             } else if (value instanceof List) { | ||||
|                 // 处理List | ||||
|                 List<?> list = (List<?>) value; | ||||
|                 for (Object item : list) { | ||||
|                     if (item instanceof Map) { | ||||
|                         xmlBuilder.append(indentStr).append("<").append(key).append(">\n"); | ||||
|                         buildXml(xmlBuilder, (Map<String, Object>) item, indent + 1); | ||||
|                         xmlBuilder.append(indentStr).append("</").append(key).append(">\n"); | ||||
|                     } else { | ||||
|                         xmlBuilder.append(indentStr).append("<").append(key).append(">") | ||||
|                                 .append(escapeXml(item.toString())) | ||||
|                                 .append("</").append(key).append(">\n"); | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 // 处理普通值 | ||||
|                 if (value == null) { | ||||
|                     xmlBuilder.append(indentStr).append("<").append(key).append("/>\n"); | ||||
|                 } else { | ||||
|                     xmlBuilder.append(indentStr).append("<").append(key).append(">") | ||||
|                             .append(escapeXml(value.toString())) | ||||
|                             .append("</").append(key).append(">\n"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * XML特殊字符转义 | ||||
|      */ | ||||
|     private static String escapeXml(String text) { | ||||
|         if (text == null) return ""; | ||||
|         return text.replace("&", "&") | ||||
|                 .replace("<", "<") | ||||
|                 .replace(">", ">") | ||||
|                 .replace("\"", """) | ||||
|                 .replace("'", "'"); | ||||
|     } | ||||
| 
 | ||||
|     // 自定义缩进方法 | ||||
|     private static String createIndent(int indent) { | ||||
|         StringBuilder sb = new StringBuilder(); | ||||
|         for (int i = 0; i < indent; i++) { | ||||
|             sb.append("    "); // 4个空格 | ||||
|         } | ||||
|         return sb.toString(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue