出差申请单保存0.2, 获取申请人的默认部门作为申请部门和费用承担部门

This commit is contained in:
李靖 2024-05-15 14:14:41 +08:00
parent 37169f571b
commit 3f5368b44b
1 changed files with 54 additions and 14 deletions

View File

@ -1,6 +1,13 @@
package shkd.fi.er.plugin; package shkd.fi.er.plugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.openapi.api.plugin.ApiSavePlugin; import kd.bos.openapi.api.plugin.ApiSavePlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
@ -8,8 +15,30 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class SaveTripBaseBillApiSavePlugin implements ApiSavePlugin { public class SaveTripBaseBillApiSavePlugin implements ApiSavePlugin {
private QFilter[] qList;
private String getUserDeptNumber(String userNumber) {
QFilter filter = new QFilter("number", QCP.equals, userNumber);
QFilter[] qList = {filter};
// DynamicObject queryOrg = BusinessDataServiceHelper.loadSingle("bos_user", qList);
DynamicObjectCollection list = QueryServiceHelper
.query("bos_user","id, entryentity.*, entryentity.dpt.*", qList);
for(DynamicObject queryOrg : list) {
long id = (long)queryOrg.get("id");
long dptId = (long)queryOrg.get("entryentity.dpt.id");
String dptNumber = queryOrg.getString("entryentity.dpt.number");
boolean isPartJob = queryOrg.getBoolean("entryentity.ispartjob");
// 返回不是兼职的部门
if(!isPartJob){
return dptNumber ;
}
}
return null;
}
@Override @Override
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) { public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
Map<String, Object> tempMap = null;
for (Map<String, Object> temp1 : reqData) { for (Map<String, Object> temp1 : reqData) {
Object multitravelers = temp1.get("multitravelers"); Object multitravelers = temp1.get("multitravelers");
if (temp1.containsKey("tripentry")) { if (temp1.containsKey("tripentry")) {
@ -19,10 +48,10 @@ public class SaveTripBaseBillApiSavePlugin implements ApiSavePlugin {
amount = amount.add((BigDecimal) tripentry.get("triporiamount")); amount = amount.add((BigDecimal) tripentry.get("triporiamount"));
tripentry.put("travelers", multitravelers); tripentry.put("travelers", multitravelers);
if (!tripentry.containsKey("tripexpenseitem")) { if (!tripentry.containsKey("tripexpenseitem")) {
Map<String, Object> tripexpenseitem = new HashMap<String, Object>(); tempMap = new HashMap<String, Object>();
//费用项目默认差旅费FYXM0015 //费用项目默认差旅费FYXM0015
tripexpenseitem.put("number", "FYXM0015"); tempMap.put("number", "FYXM0015");
tripentry.put("tripexpenseitem", tripexpenseitem); tripentry.put("tripexpenseitem", tempMap);
//交通工具默认其它工具 [1:飞机, 2:火车, 3:汽车, 4:轮船, 5:其他工具] //交通工具默认其它工具 [1:飞机, 2:火车, 3:汽车, 4:轮船, 5:其他工具]
tripentry.put("vehicles", "5"); tripentry.put("vehicles", "5");
} }
@ -31,13 +60,24 @@ public class SaveTripBaseBillApiSavePlugin implements ApiSavePlugin {
temp1.put("approveamount", amount); temp1.put("approveamount", amount);
} }
if (!temp1.containsKey("triptype")) { if (!temp1.containsKey("triptype")) {
Map<String, Object> triptype = new HashMap<String, Object>(); tempMap = new HashMap<String, Object>();
//出差类型默认值普通出差001 //出差类型默认值普通出差001
triptype.put("number", "001"); tempMap.put("number", "001");
temp1.put("triptype", triptype); temp1.put("triptype", tempMap);
} }
temp1.put("istravelers", true); temp1.put("istravelers", true);
// temp1.put("billstatus", "C"); Map<String, Object> applierMap = (Map<String, Object>)temp1.get("applier");
String deptNumber = getUserDeptNumber(String.valueOf(applierMap.get("number")));//10000872
if (!temp1.containsKey("org")) {
tempMap = new HashMap<String, Object>();
tempMap.put("number", deptNumber);
temp1.put("org", tempMap);
}
if (!temp1.containsKey("costdept")) {
tempMap = new HashMap<String, Object>();
tempMap.put("number", deptNumber);
temp1.put("costdept", tempMap);
}
} }
return reqData; return reqData;
} }