客户接口优化
This commit is contained in:
		
							parent
							
								
									024ea6e161
								
							
						
					
					
						commit
						c304a7e581
					
				|  | @ -7,7 +7,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper; | |||
| import kd.sdk.plugin.Plugin; | ||||
| 
 | ||||
| /** | ||||
|  * 单据操作插件 | ||||
|  * 支付信息变更单据操作插件 | ||||
|  */ | ||||
| public class PayinfoChangeOperation extends AbstractOperationServicePlugIn implements Plugin { | ||||
| 
 | ||||
|  |  | |||
|  | @ -39,23 +39,22 @@ public class EsbUtils { | |||
| 
 | ||||
|     //处理分配 | ||||
|     public static void handleAssign(JSONArray companysJson, Map<String, Long> cusids, String entityName) { | ||||
|         if(companysJson == null){ | ||||
|         if(companysJson == null || cusids.isEmpty()){ | ||||
|             return; | ||||
|         } | ||||
|         JSONObject json_body; | ||||
|         String compnum; | ||||
|         String cusnumber = ""; | ||||
|         String cusnumber = "";//当前编号 | ||||
|         String firstnumber = "firstnumber";//初始化编号 | ||||
|         Long curid;//当前数据id | ||||
|         DynamicObject compinfo; | ||||
|         List<Long> dataList = new ArrayList<>(); | ||||
|         List<Long> orgList = new ArrayList<>(); | ||||
|         for (int i = 0; i < companysJson.size(); i++) { | ||||
|             json_body = companysJson.getJSONObject(i); | ||||
|             if(i == 0){ | ||||
|                 //初始化 | ||||
|             cusnumber = json_body.getString("code");//客户-供应商编号 | ||||
|             } | ||||
|             compnum = json_body.getString("companynum");//公司编号 | ||||
|             if(EsbUtils.isEmpty(compnum) || "0".equals(json_body.getString("companystatus"))){ | ||||
|             if(EsbUtils.isEmpty(cusnumber) || EsbUtils.isEmpty(compnum) || "0".equals(json_body.getString("companystatus"))){ | ||||
|                 //公司编号为空 或者 公司层面使用状态-禁用的 不处理 | ||||
|                 continue; | ||||
|             } | ||||
|  | @ -64,49 +63,61 @@ public class EsbUtils { | |||
|             if(compinfo == null){ | ||||
|                 continue; | ||||
|             } | ||||
|             if(cusnumber.equals(json_body.getString("code"))){ | ||||
|             if("firstnumber".equals(firstnumber)){ | ||||
|                 //初始化,改变初始化值 | ||||
|                 firstnumber = cusnumber; | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             }else if(firstnumber.equals(cusnumber)){ | ||||
|                 //还是同一个客户 | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             }else{ | ||||
|                 //另一个客户,先处理上一个客户的分配 | ||||
|                 if(!orgList.isEmpty()){ | ||||
|                     curid = cusids.get(cusnumber); | ||||
|                     if(curid == null){ | ||||
|                         //当前编号对应的id不存在,即上一个数据没有保存成功 不处理分配,上一个组织数据清空,增加当前组织 | ||||
|                         orgList.clear(); | ||||
|                         orgList.add(compinfo.getLong("id")); | ||||
|                         continue; | ||||
|                     } | ||||
|                     dataList.clear(); | ||||
|                     dataList.add(cusids.get(cusnumber)); | ||||
|                     dataList.add(curid); | ||||
|                     BaseDataServiceHelper.batchAssignWithDetail(entityName,JhzjUtils.GROUPID,dataList,orgList); | ||||
|                     //处理完成后,清空组织列表 | ||||
|                     orgList.clear(); | ||||
|                     orgList.add(compinfo.getLong("id")); | ||||
|                 } | ||||
|                 cusnumber = json_body.getString("code"); | ||||
|                 firstnumber = cusnumber; | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             } | ||||
|         } | ||||
|         curid = cusids.get(cusnumber); | ||||
|         //考虑最后一个客户的分配情况 | ||||
|         if(!orgList.isEmpty()){ | ||||
|         if(!orgList.isEmpty() && curid != null){ | ||||
|             dataList.clear(); | ||||
|             dataList.add(cusids.get(cusnumber)); | ||||
|             dataList.add(curid); | ||||
|             BaseDataServiceHelper.batchAssignWithDetail(entityName,JhzjUtils.GROUPID,dataList,orgList); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     //处理取消分配 | ||||
|     public static void handleUnAssign(JSONArray companysJson, Map<String, Long> cusids, String entityName) { | ||||
|         if(companysJson == null){ | ||||
|         if(companysJson == null || cusids.isEmpty()){ | ||||
|             return; | ||||
|         } | ||||
|         JSONObject json_body; | ||||
|         String compnum; | ||||
|         String cusnumber = ""; | ||||
|         String cusnumber = "";//当前编号 | ||||
|         String firstnumber = "firstnumber";//初始化编号 | ||||
|         Long curid;//当前数据id | ||||
|         DynamicObject compinfo; | ||||
|         Set<Long> dataList = new HashSet<>(); | ||||
|         Set<Long> orgList = new HashSet<>(); | ||||
|         for (int i = 0; i < companysJson.size(); i++) { | ||||
|             json_body = companysJson.getJSONObject(i); | ||||
|             if(i == 0){ | ||||
|                 //初始化 | ||||
|             cusnumber = json_body.getString("code");//客户-供应商编号 | ||||
|             } | ||||
|             compnum = json_body.getString("companynum");//公司编号 | ||||
|             if(EsbUtils.isEmpty(compnum) || "1".equals(json_body.getString("companystatus"))){ | ||||
|             if(EsbUtils.isEmpty(cusnumber) || EsbUtils.isEmpty(compnum) || "1".equals(json_body.getString("companystatus"))){ | ||||
|                 //公司编号为空 或者 公司层面使用状态-启用的 不处理 | ||||
|                 continue; | ||||
|             } | ||||
|  | @ -115,26 +126,39 @@ public class EsbUtils { | |||
|             if(compinfo == null){ | ||||
|                 continue; | ||||
|             } | ||||
|             if(cusnumber.equals(json_body.getString("code"))){ | ||||
|             if("firstnumber".equals(firstnumber)){ | ||||
|                 //初始化,改变初始化值 | ||||
|                 firstnumber = cusnumber; | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             }else if(firstnumber.equals(cusnumber)){ | ||||
|                 //还是同一个客户 | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             }else{ | ||||
|                 //另一个客户,先处理上一个客户的取消分配 | ||||
|                 if(!orgList.isEmpty()){ | ||||
|                     curid = cusids.get(cusnumber); | ||||
|                     if(curid == null){ | ||||
|                         //当前编号对应的id不存在,即上一个数据没有保存成功 不处理取消分配,上一个组织数据清空,增加当前组织 | ||||
|                         orgList.clear(); | ||||
|                         orgList.add(compinfo.getLong("id")); | ||||
|                         continue; | ||||
|                     } | ||||
|                     dataList.clear(); | ||||
|                     dataList.add(cusids.get(cusnumber)); | ||||
|                     dataList.add(curid); | ||||
|                     BaseDataServiceHelper.cancelAssign(entityName,dataList,orgList); | ||||
|                     //处理完成后,清空组织列表 | ||||
|                     //处理完成后,清空上一个组织列表,增加当前组织 | ||||
|                     orgList.clear(); | ||||
|                     orgList.add(compinfo.getLong("id")); | ||||
|                 } | ||||
|                 cusnumber = json_body.getString("code"); | ||||
|                 firstnumber = cusnumber; | ||||
|                 orgList.add(compinfo.getLong("id")); | ||||
|             } | ||||
|         } | ||||
|         curid = cusids.get(cusnumber); | ||||
|         //考虑最后一个客户的取消分配情况 | ||||
|         if(!orgList.isEmpty()){ | ||||
|         if(!orgList.isEmpty() && curid != null){ | ||||
|             dataList.clear(); | ||||
|             dataList.add(cusids.get(cusnumber)); | ||||
|             dataList.add(curid); | ||||
|             BaseDataServiceHelper.cancelAssign(entityName,dataList,orgList); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -157,6 +157,9 @@ public class CustomerControler { | |||
|                 //处理 客户组5 | ||||
|                 handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); | ||||
|                 //TODO 银行信息 | ||||
|                 if(!"M400".equals(type)){ | ||||
|                     handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber); | ||||
|                 } | ||||
|                 SaveServiceHelper.save(new DynamicObject[]{currentCus}); | ||||
|             } | ||||
|             cusids.put(cusnumber,currentSupId); | ||||
|  | @ -186,8 +189,12 @@ public class CustomerControler { | |||
|             json_body = customerfivesJson.getJSONObject(i); | ||||
|             if(cusnumber.equals(json_body.getString("code"))){ | ||||
|                 fiveinfo = doc_five.addNew(); | ||||
|                 fiveinfo.set("shjh_channelnum",json_body.getString("channelnum"));//渠道编号 | ||||
|                 fiveinfo.set("shjh_channelname",json_body.getString("channelname"));//渠道名称 | ||||
|                 fiveinfo.set("shjh_salecompanynum",json_body.getString("salecompanynum"));//公司编号 | ||||
|                 fiveinfo.set("shjh_entryfive_number",json_body.getString("customerfivecode"));//编号 | ||||
|                 fiveinfo.set("shjh_entryfive_name",json_body.getString("customerfivename"));//名称 | ||||
|                 fiveinfo.set("shjh_status",json_body.getString("customerfivestatus"));//状态 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -196,6 +203,7 @@ public class CustomerControler { | |||
|         if(banksJson == null){ | ||||
|             return; | ||||
|         } | ||||
|         doc_bank.clear(); | ||||
|         JSONObject json_body; | ||||
|         DynamicObject bankinfo; | ||||
|         DynamicObject bebankinfo; | ||||
|  |  | |||
|  | @ -183,6 +183,14 @@ public class CustomerModel implements Serializable { | |||
|         private String customerfivecode; | ||||
|         @ApiParam(value="客户组5名称",position=3) | ||||
|         private String customerfivename; | ||||
|         @ApiParam(value="分销渠道编号",position=4) | ||||
|         private String channelnum; | ||||
|         @ApiParam(value="分销渠道名称",position=5) | ||||
|         private String channelname; | ||||
|         @ApiParam(value="销售公司编号",position=6) | ||||
|         private String salecompanynum; | ||||
|         @ApiParam(value="客户组5使用状态",position=7) | ||||
|         private String customerfivestatus; | ||||
| 
 | ||||
|         public String getCode() { | ||||
|             return code; | ||||
|  | @ -207,6 +215,38 @@ public class CustomerModel implements Serializable { | |||
|         public void setCustomerfivename(String customerfivename) { | ||||
|             this.customerfivename = customerfivename; | ||||
|         } | ||||
| 
 | ||||
|         public String getChannelnum() { | ||||
|             return channelnum; | ||||
|         } | ||||
| 
 | ||||
|         public void setChannelnum(String channelnum) { | ||||
|             this.channelnum = channelnum; | ||||
|         } | ||||
| 
 | ||||
|         public String getChannelname() { | ||||
|             return channelname; | ||||
|         } | ||||
| 
 | ||||
|         public void setChannelname(String channelname) { | ||||
|             this.channelname = channelname; | ||||
|         } | ||||
| 
 | ||||
|         public String getSalecompanynum() { | ||||
|             return salecompanynum; | ||||
|         } | ||||
| 
 | ||||
|         public void setSalecompanynum(String salecompanynum) { | ||||
|             this.salecompanynum = salecompanynum; | ||||
|         } | ||||
| 
 | ||||
|         public String getCustomerfivestatus() { | ||||
|             return customerfivestatus; | ||||
|         } | ||||
| 
 | ||||
|         public void setCustomerfivestatus(String customerfivestatus) { | ||||
|             this.customerfivestatus = customerfivestatus; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @ApiModel | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue