1.共享任务中心凭证批量复制和删除功能

2.差旅报销单报单往来家居明细控制功能优化
This commit is contained in:
zhangzhiguo 2025-04-10 09:47:19 +08:00
parent 5975ccb143
commit 34a9e63c49
3 changed files with 119 additions and 13 deletions
code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin

View File

@ -27,7 +27,6 @@ public class AccountsitemsmapImpPlugin extends AbstractBillPlugIn {
for (Map.Entry<BasedataItem, List<Object>> baseDataItemListEntry : searchResult.entrySet()) {
BasedataItem basedataItem = baseDataItemListEntry.getKey();
if (basedataItem.getFieldKey().equals(ACCOUNT_ITEM)) {//判断当前基础资料是否为 会计科目
//遍历物料的内码根据内码拿到物料的数据包选择长度为 20 电风扇
for (int i = 0;i < baseDataItemListEntry.getValue().size();i++){
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(baseDataItemListEntry.getValue().get(i), basedataItem.getEntityNumber());
String tableNumber = ((DynamicObject) dynamicObject.get("accounttable")).getString("number");

View File

@ -8,8 +8,11 @@ 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.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
import kd.bos.list.ListFilterParameter;
import kd.bos.list.ListShowParameter;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
@ -17,7 +20,10 @@ 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.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.*;
@ -37,13 +43,14 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
Map<String,String> messageBill = new HashMap<>();
StringBuilder sb = new StringBuilder();
if(selectedRows.isEmpty()){
this.getView().showTipNotification(String.format("请选择需要生成凭证的数据。"));
return;
}
List<Long> voucherIds = new ArrayList<>();
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;
@ -64,27 +71,122 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
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++;
//单据ID:凭证ID:凭证编码
//{"2189115272965662720":"2189115761987977216:10006834-000001"}
JSONObject data = JSON.parseObject(String.valueOf(map.get("data")));
if(data!=null){
String voucherInfo = data.getString(billid);
String voucherIdStr = voucherInfo.split(":")[0];
voucherIds.add(Long.valueOf(voucherIdStr));
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));
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(String.format("凭证生成完成,一共%d条成功%d条失败%d条。",allCount,successCount,errorCount));
}
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);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows.isEmpty()){
this.getView().showTipNotification(String.format("请选择需要删除凭证的数据。"));
return;
}
List<Long> voucherIds = new ArrayList<>();
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");
DynamicObject bindbill = billtype.getDynamicObject("bindbill"); //源单
String entityName = bindbill.getString("number");
//String vouchernum = bindbill.getString("vouchernum");
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))
});
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:凭证编码
/*{
"data":{
"failCount":"0",
"filter":"[id IN (2189353147254737920)]",
"result":[
{
"billStatus":true,
"errors":[],
"id":"2189353147254737920",
"number":"10006834-000004"
}
],
"successCount":"1",
"totalCount":"1"
},
"errorCode":"0",
"message":null,
"status":true
}*/
successCount++;
}else{
errorCount++;
log.info("TaskListBuildVoucherPlugin-delete: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");//调用表单的刷新操作
}
}
}

View File

@ -87,6 +87,7 @@ public class TripreimbursebillIsHomeCheckOp extends AbstractOperationServicePlug
String message = String.format("提交人没有往来居家配置。");
this.addFatalErrorMessage(extendedDataEntity, message);
}
int monthTime = 0;
for (Row row : homeDataSet) {
monthTime = row.getInteger("monthTime");
@ -97,6 +98,9 @@ public class TripreimbursebillIsHomeCheckOp extends AbstractOperationServicePlug
Map<String,Integer> homeentityCountMap = new HashMap<>();
int i = 1;
if(tripentry==null || tripentry.isEmpty()){
this.addFatalErrorMessage(extendedDataEntity, String.format("请录入往来居家明细数据"));
}
for (DynamicObject dynamicObject : tripentry) {
Date bxmonth = dynamicObject.getDate("zcgj_bxmonth");
String yearMonth = dateFormat.format(bxmonth);
@ -163,6 +167,7 @@ public class TripreimbursebillIsHomeCheckOp extends AbstractOperationServicePlug
}
}
}
}
}
}