共享合并生成凭证问题
This commit is contained in:
		
							parent
							
								
									f0115bb5d3
								
							
						
					
					
						commit
						0caafcd63d
					
				| 
						 | 
				
			
			@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 | 
			
		|||
import com.alibaba.fastjson.TypeReference;
 | 
			
		||||
import kd.bos.dataentity.OperateOption;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.resource.ResManager;
 | 
			
		||||
import kd.bos.entity.EntityMetadataCache;
 | 
			
		||||
import kd.bos.entity.datamodel.ListSelectedRow;
 | 
			
		||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
 | 
			
		||||
| 
						 | 
				
			
			@ -96,11 +97,6 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
 | 
			
		|||
                    List<IOperateInfo> allErrorInfo = operationResult.getAllErrorOrValidateInfo();
 | 
			
		||||
                    allErrorInfo.forEach((error) -> sb.append(error.getMessage()));
 | 
			
		||||
                    errorCount++;
 | 
			
		||||
                   // view.showTipNotification(sb.toString());
 | 
			
		||||
                   // for (IOperateInfo iOperateInfo : allErrorInfo) {
 | 
			
		||||
 | 
			
		||||
                   // }
 | 
			
		||||
                   // log.info("生成凭证失败,单据id:" + billid + ",失败原因:" + sb);
 | 
			
		||||
                } else {
 | 
			
		||||
                    //VoucherUtil.viewVoucher(billid, this.getView(), true);
 | 
			
		||||
                    List<Object> successPkIds = operationResult.getSuccessPkIds();
 | 
			
		||||
| 
						 | 
				
			
			@ -137,92 +133,11 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
 | 
			
		|||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                //this.getView().showSuccessNotification(String.format("凭证生成完成。"));
 | 
			
		||||
 | 
			
		||||
            }else{//有失败的,使用警告弹框提醒
 | 
			
		||||
                //this.getView().showTipNotification(String.format("凭证生成完成,一共%d条,成功:%d条,失败:%d条。",allCount,successCount,errorCount));
 | 
			
		||||
                this.getView().showTipNotification(sb.toString());
 | 
			
		||||
            }
 | 
			
		||||
            this.getView().invokeOperation("refresh");//调用表单的刷新操作
 | 
			
		||||
 | 
			
		||||
            //如果有成功生成的凭证,则调整到凭证列表页面
 | 
			
		||||
            /*if(successCount != 0){
 | 
			
		||||
                try {
 | 
			
		||||
                    Thread.sleep(100L);
 | 
			
		||||
                } catch (InterruptedException e) {
 | 
			
		||||
                    throw new RuntimeException(e);
 | 
			
		||||
                }
 | 
			
		||||
                ListShowParameter listShowParameter = new ListShowParameter();
 | 
			
		||||
                listShowParameter.setFormId("bos_list");
 | 
			
		||||
                listShowParameter.setBillFormId("gl_voucher");
 | 
			
		||||
                listShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
 | 
			
		||||
                // 设置联查PK
 | 
			
		||||
                for (Long voucherId : voucherIds) {
 | 
			
		||||
                    listShowParameter.addLinkQueryPkId(voucherId);
 | 
			
		||||
                }
 | 
			
		||||
                this.getView().showForm(listShowParameter);
 | 
			
		||||
            }*/
 | 
			
		||||
 | 
			
		||||
            /*for (String entityName : map.keySet()) {
 | 
			
		||||
                List<String> billIdList = map.get(entityName);
 | 
			
		||||
                Map<String,Object> params = new HashMap<String,Object>();
 | 
			
		||||
                params.put("billType", entityName);
 | 
			
		||||
                params.put("billIds", billIdList);
 | 
			
		||||
                params.put("params", par);
 | 
			
		||||
                OpenApiResult invoke = OpenApiSdkUtil.invoke("/v2/ai/buildVoucher", params);
 | 
			
		||||
                Map<String, Object> resultMap = invoke.toMap();
 | 
			
		||||
                if(resultMap.get("status").toString().equals("true")){
 | 
			
		||||
                    //单据ID:凭证ID:凭证编码
 | 
			
		||||
                    //{"2189115272965662720":"2189115761987977216:10006834-000001"}
 | 
			
		||||
                    Map<String, String> dataMap = JSON.parseObject(String.valueOf(resultMap.get("data")), new TypeReference<Map<String, String>>() {});
 | 
			
		||||
                    //JSONObject data = JSON.parseObject(String.valueOf(resultMap.get("data")));
 | 
			
		||||
                    if(dataMap!=null){
 | 
			
		||||
                        for (String voucherInfo : dataMap.keySet()) {
 | 
			
		||||
                            String voucherIdStr = voucherInfo.split(":")[0];
 | 
			
		||||
                            voucherIds.add(Long.valueOf(voucherIdStr));
 | 
			
		||||
                        }
 | 
			
		||||
                        successCount++;
 | 
			
		||||
                    }
 | 
			
		||||
                }else{
 | 
			
		||||
                    errorCount++;
 | 
			
		||||
                    Map<String, String> stringStringMap = JSON.parseObject(invoke.getMessage(), new TypeReference<Map<String, String>>() {
 | 
			
		||||
                    });
 | 
			
		||||
                    Collection<String> values = stringStringMap.values();
 | 
			
		||||
                    Object[] array = values.toArray();
 | 
			
		||||
                    String  msg = String.valueOf(array[0]);
 | 
			
		||||
                    sb.append(String.format("单据编号:生成凭证失败,失败原因:【%s】;",msg));
 | 
			
		||||
                    VoucherUtil.viewVoucher("", this.getView(), true);
 | 
			
		||||
                    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().showTipNotification(sb.toString());
 | 
			
		||||
            }
 | 
			
		||||
            this.getView().invokeOperation("refresh");//调用表单的刷新操作
 | 
			
		||||
 | 
			
		||||
            //如果有成功生成的凭证,则调整到凭证列表页面
 | 
			
		||||
            if(successCount != 0){
 | 
			
		||||
                try {
 | 
			
		||||
                    Thread.sleep(100L);
 | 
			
		||||
                } catch (InterruptedException e) {
 | 
			
		||||
                    throw new RuntimeException(e);
 | 
			
		||||
                }
 | 
			
		||||
                ListShowParameter listShowParameter = new ListShowParameter();
 | 
			
		||||
                listShowParameter.setFormId("bos_list");
 | 
			
		||||
                listShowParameter.setBillFormId("gl_voucher");
 | 
			
		||||
                listShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
 | 
			
		||||
                // 设置联查PK
 | 
			
		||||
                for (Long voucherId : voucherIds) {
 | 
			
		||||
                    listShowParameter.addLinkQueryPkId(voucherId);
 | 
			
		||||
                }
 | 
			
		||||
                this.getView().showForm(listShowParameter);
 | 
			
		||||
            }*/
 | 
			
		||||
        }
 | 
			
		||||
        else if("zcgj_deletevoucher".equals(itemKey)){
 | 
			
		||||
            BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
 | 
			
		||||
| 
						 | 
				
			
			@ -237,6 +152,7 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
 | 
			
		|||
            int allCount =0;
 | 
			
		||||
            int successCount =0;
 | 
			
		||||
            StringBuilder sb = new StringBuilder();
 | 
			
		||||
            Map<String,List<String>> map = new HashMap<>();
 | 
			
		||||
            for (ListSelectedRow selectedRow : selectedRows) {
 | 
			
		||||
                Long pk = (Long) selectedRow.getPrimaryKeyValue();
 | 
			
		||||
                DynamicObject taskobj = BusinessDataServiceHelper.loadSingle(pk, "task_task");
 | 
			
		||||
| 
						 | 
				
			
			@ -248,38 +164,42 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
 | 
			
		|||
                String billid = taskobj.getString("billid");
 | 
			
		||||
                //log.info("TaskListBuildVoucherPlugin-delete:vouchernum:"+vouchernum);
 | 
			
		||||
                log.info("TaskListBuildVoucherPlugin-delete:billid:"+billid);
 | 
			
		||||
                if(billid!=null && !billid.isEmpty() ){
 | 
			
		||||
                    DynamicObject voucherObject = BusinessDataServiceHelper.loadSingle("gl_voucher", "id",
 | 
			
		||||
                            new QFilter[]{new QFilter("sourcebill", QCP.equals, Long.valueOf(billid))
 | 
			
		||||
                                    .and(new QFilter("sourcebilltype.number", QCP.equals, entityName))
 | 
			
		||||
                                    //.and(new QFilter("billno", QCP.equals, vouchernum))
 | 
			
		||||
                            });
 | 
			
		||||
                    if(voucherObject != null){
 | 
			
		||||
                        long voucherId = voucherObject.getLong("id");
 | 
			
		||||
                        log.info("TaskListBuildVoucherPlugin-delete:voucherId:"+voucherId);
 | 
			
		||||
                        Map<String,Object> params = new HashMap<String,Object>();
 | 
			
		||||
                        Map<String,Long> idMap = new HashMap<>();
 | 
			
		||||
                        idMap.put("id", voucherId);
 | 
			
		||||
                        params.put("data",idMap);
 | 
			
		||||
                        OpenApiResult invoke = OpenApiSdkUtil.invoke("/v2/gl/gl_voucher/delete", params);
 | 
			
		||||
                        Map<String, Object> map = invoke.toMap();
 | 
			
		||||
                        if(map.get("status").toString().equals("true")){
 | 
			
		||||
                            //单据ID:凭证ID:凭证编码
 | 
			
		||||
                            successCount++;
 | 
			
		||||
                        }else{
 | 
			
		||||
                            errorCount++;
 | 
			
		||||
                            sb.append(String.format(invoke.getMessage()));
 | 
			
		||||
                            log.info("TaskListBuildVoucherPlugin-delete:error:"+invoke.getMessage());
 | 
			
		||||
                        }
 | 
			
		||||
                    }else{
 | 
			
		||||
                        errorCount++;
 | 
			
		||||
                        sb.append(String.format("单据编号:【%s】,尚未生成凭证。",billnumber));
 | 
			
		||||
                    }
 | 
			
		||||
                    allCount++;
 | 
			
		||||
                if(map.containsKey(entityName)){
 | 
			
		||||
                    map.get(entityName).add(billid);
 | 
			
		||||
                }else{
 | 
			
		||||
                    List<String> idList =  new ArrayList<>();
 | 
			
		||||
                    idList.add(billid);
 | 
			
		||||
                    map.put(entityName,idList);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            OperateOption option = OperateOption.create();
 | 
			
		||||
            OperationResult operationResult = null;
 | 
			
		||||
            Map<String, Object> voucherOperate = null;
 | 
			
		||||
            for (String entityName : map.keySet()) {
 | 
			
		||||
                List<String> billIds = map.get(entityName);
 | 
			
		||||
                for (String billId : billIds) {
 | 
			
		||||
                    List<Long> vouncherids = VoucherUtil.getVouncheridByBillid(Long.parseLong(billId));
 | 
			
		||||
                    if (vouncherids.isEmpty()) {
 | 
			
		||||
                        this.getView().showTipNotification(ResManager.loadKDString("单据不存在关联凭证。", "VoucherUtil_4", "ssc-task-formplugin", new Object[0]));
 | 
			
		||||
                    }else{
 | 
			
		||||
                        voucherOperate = EntityMetadataCache.getDataEntityOperate(entityName, "deletevoucher");
 | 
			
		||||
                        operationResult = OperationServiceHelper.executeOperate((String)voucherOperate.get("key"), entityName, billIds.toArray(), option);
 | 
			
		||||
                        if (!operationResult.isSuccess()) {
 | 
			
		||||
                            List<IOperateInfo> allErrorInfo = operationResult.getAllErrorOrValidateInfo();
 | 
			
		||||
                            allErrorInfo.forEach((error) -> sb.append(error.getMessage()));
 | 
			
		||||
                           // this.getView().showTipNotification(sb.toString());
 | 
			
		||||
                            log.info("删除凭证失败,单据id:" + billId + ",失败原因:" + sb);
 | 
			
		||||
                            errorCount++;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            if(errorCount == 0){//没有失败的,使用成功弹框提醒
 | 
			
		||||
                this.getView().showSuccessNotification(String.format("删除凭证完成,一共%d条,成功:%d条,失败:%d条。",allCount,successCount,errorCount));
 | 
			
		||||
              //  this.getView().showSuccessNotification(String.format("删除凭证完成,一共%d条,成功:%d条,失败:%d条。",allCount,successCount,errorCount));
 | 
			
		||||
                String text = "成功删除凭证。";
 | 
			
		||||
                this.getView().showSuccessNotification(String.format(ResManager.loadKDString(" %s", "TaskVoucherApproveFormPlugin_3", "ssc-task-formplugin", new Object[0]), text));
 | 
			
		||||
            }else{//有失败的,使用警告弹框提醒
 | 
			
		||||
                //this.getView().showTipNotification(String.format("删除凭证完成,一共%d条,成功:%d条,失败:%d条。",allCount,successCount,errorCount));
 | 
			
		||||
                this.getView().showTipNotification(sb.toString());
 | 
			
		||||
| 
						 | 
				
			
			@ -287,29 +207,6 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
 | 
			
		|||
            this.getView().invokeOperation("refresh");//调用表单的刷新操作
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        /*else if("zcgj_bar_payp".equals(itemKey)){
 | 
			
		||||
            BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
 | 
			
		||||
            //获取到选中行的数据
 | 
			
		||||
            ListSelectedRowCollection selectedRows = billList.getSelectedRows();
 | 
			
		||||
            if(selectedRows.isEmpty()){
 | 
			
		||||
                this.getView().showTipNotification(String.format("请选择需要付款的数据。"));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            for (ListSelectedRow selectedRow : selectedRows) {
 | 
			
		||||
                Long pk = (Long) selectedRow.getPrimaryKeyValue();
 | 
			
		||||
                DynamicObject taskobj = BusinessDataServiceHelper.loadSingle(pk, "task_task");
 | 
			
		||||
                DynamicObject billtype = taskobj.getDynamicObject("billtype");
 | 
			
		||||
                DynamicObject bindbill = billtype.getDynamicObject("bindbill"); //源单
 | 
			
		||||
                String entityName = bindbill.getString("number");
 | 
			
		||||
                String billid = taskobj.getString("billid");
 | 
			
		||||
                OperateOption operateOption = OperateOption.create();
 | 
			
		||||
                QFilter accountTableFilter = new QFilter("id", QCP.equals,Long.valueOf(billid));
 | 
			
		||||
                DynamicObject sourceBillObject = BusinessDataServiceHelper.loadSingle(entityName,  new QFilter[]{accountTableFilter});
 | 
			
		||||
                OperationResult opResult= OperationServiceHelper.executeOperate("pushpaybill", entityName, new DynamicObject[] {sourceBillObject},operateOption );
 | 
			
		||||
                //OperationResult opResult= OperationServiceHelper.executeOperate("pushpaybill", entityName, new DynamicObject[] {sourceBillObject},operateOption );
 | 
			
		||||
                log.info(opResult.toString());
 | 
			
		||||
            }
 | 
			
		||||
        }*/
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue