1.任务共享中心批量生成凭证功能
This commit is contained in:
		
							parent
							
								
									898165509b
								
							
						
					
					
						commit
						5905dfac07
					
				| 
						 | 
					@ -0,0 +1,90 @@
 | 
				
			||||||
 | 
					package zcgj.zcdev.zcdev.fs.plugin.form;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.JSON;
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.JSONObject;
 | 
				
			||||||
 | 
					import com.fasterxml.jackson.databind.ObjectMapper;
 | 
				
			||||||
 | 
					import kd.ai.ids.core.utils.JsonUtils;
 | 
				
			||||||
 | 
					import kd.bos.bill.AbstractBillPlugIn;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObject;
 | 
				
			||||||
 | 
					import kd.bos.entity.datamodel.ListSelectedRow;
 | 
				
			||||||
 | 
					import kd.bos.entity.datamodel.ListSelectedRowCollection;
 | 
				
			||||||
 | 
					import kd.bos.form.control.events.ItemClickEvent;
 | 
				
			||||||
 | 
					import kd.bos.list.BillList;
 | 
				
			||||||
 | 
					import kd.bos.list.plugin.AbstractListPlugin;
 | 
				
			||||||
 | 
					import kd.bos.logging.Log;
 | 
				
			||||||
 | 
					import kd.bos.logging.LogFactory;
 | 
				
			||||||
 | 
					import kd.bos.openapi.common.result.OpenApiResult;
 | 
				
			||||||
 | 
					import kd.bos.openapi.common.util.JacksonUtil;
 | 
				
			||||||
 | 
					import kd.bos.openapi.common.util.JsonUtil;
 | 
				
			||||||
 | 
					import kd.bos.openapi.common.util.OpenApiSdkUtil;
 | 
				
			||||||
 | 
					import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
				
			||||||
 | 
					import kd.sdk.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 共享任务中心-我的任务-批量生成凭证插件
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Plugin {
 | 
				
			||||||
 | 
					    private static final Log log = LogFactory.getLog(TaskListBuildVoucherPlugin.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void itemClick(ItemClickEvent evt) {
 | 
				
			||||||
 | 
					        super.itemClick(evt);
 | 
				
			||||||
 | 
					        String itemKey = evt.getItemKey();
 | 
				
			||||||
 | 
					        if("zcgj_buildvoucher".equals(itemKey)) {
 | 
				
			||||||
 | 
					            BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
 | 
				
			||||||
 | 
					            //获取到选中行的数据
 | 
				
			||||||
 | 
					            ListSelectedRowCollection selectedRows = billList.getSelectedRows();
 | 
				
			||||||
 | 
					            Map<String,String> messageBill = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            StringBuilder sb = new StringBuilder();
 | 
				
			||||||
 | 
					            Map<String,String> par= new HashMap<>();
 | 
				
			||||||
 | 
					            par.put("$key$","");//冗余参数
 | 
				
			||||||
 | 
					            par.put("$value$","");//冗余参数
 | 
				
			||||||
 | 
					            Map<String,List<String>> billMap = new HashMap<String,List<String>>();
 | 
				
			||||||
 | 
					            int errorCount =0;
 | 
				
			||||||
 | 
					            int allCount =0;
 | 
				
			||||||
 | 
					            int successCount =0;
 | 
				
			||||||
 | 
					            for (ListSelectedRow selectedRow : selectedRows) {
 | 
				
			||||||
 | 
					                Long pk = (Long) selectedRow.getPrimaryKeyValue();
 | 
				
			||||||
 | 
					                DynamicObject taskobj = BusinessDataServiceHelper.loadSingle(pk, "task_task");
 | 
				
			||||||
 | 
					                DynamicObject billtype = taskobj.getDynamicObject("billtype");
 | 
				
			||||||
 | 
					                String entityName = billtype.getDynamicObject("bindbill").getString("number");
 | 
				
			||||||
 | 
					                String billid = taskobj.getString("billid");
 | 
				
			||||||
 | 
					                //messageBill.put(billid,taskobj.getString("billnumber")+":"+taskobj.getString("subject"));
 | 
				
			||||||
 | 
					                log.info("TaskListBuildVoucherPlugin:billid:"+billid);
 | 
				
			||||||
 | 
					                Map<String,Object> params = new HashMap<String,Object>();
 | 
				
			||||||
 | 
					                params.put("billType", entityName);
 | 
				
			||||||
 | 
					                List<String> idList =  new ArrayList<>();
 | 
				
			||||||
 | 
					                idList.add(billid);
 | 
				
			||||||
 | 
					                params.put("billIds", idList);
 | 
				
			||||||
 | 
					                params.put("params", par);
 | 
				
			||||||
 | 
					                OpenApiResult invoke = OpenApiSdkUtil.invoke("/v2/ai/buildVoucher", params);
 | 
				
			||||||
 | 
					                Map<String, Object> map = invoke.toMap();
 | 
				
			||||||
 | 
					                if(map.get("status").toString().equals("true")){
 | 
				
			||||||
 | 
					                    //JSONObject data = JSON.parseObject(String.valueOf(map.get("data")));
 | 
				
			||||||
 | 
					                    log.info("TaskListBuildVoucherPlugin:success:"+invoke.getData());
 | 
				
			||||||
 | 
					                    successCount++;
 | 
				
			||||||
 | 
					                }else{
 | 
				
			||||||
 | 
					                    errorCount++;
 | 
				
			||||||
 | 
					                    log.info("TaskListBuildVoucherPlugin:error:"+invoke.getMessage());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                allCount++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(errorCount == 0){//没有失败的,使用成功弹框提醒
 | 
				
			||||||
 | 
					                this.getView().showSuccessNotification(String.format("凭证生成完成,一共%d条,成功:%d条,失败:%d条。请在【财务云-总账-凭证】中查看已生成的凭证。",allCount,successCount,errorCount));
 | 
				
			||||||
 | 
					            }else{//有失败的,使用警告弹框提醒
 | 
				
			||||||
 | 
					                this.getView().showTipNotification(String.format("凭证生成完成,一共%d条,成功:%d条,失败:%d条。请在【财务云-总账-凭证】中查看已生成的凭证。",allCount,successCount,errorCount));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            this.getView().invokeOperation("refresh");//调用表单的刷新操作
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue