出差申请单保存0.2, 获取申请人的默认部门作为申请部门和费用承担部门
This commit is contained in:
parent
37169f571b
commit
3f5368b44b
|
@ -1,6 +1,13 @@
|
|||
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.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.util.HashMap;
|
||||
|
@ -8,21 +15,43 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
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
|
||||
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
||||
for(Map<String, Object> temp1 : reqData) {
|
||||
Map<String, Object> tempMap = null;
|
||||
for (Map<String, Object> temp1 : reqData) {
|
||||
Object multitravelers = temp1.get("multitravelers");
|
||||
if(temp1.containsKey("tripentry")){
|
||||
List<Map<String, Object>> tripentryList = (List<Map<String, Object>>)temp1.get("tripentry");
|
||||
if (temp1.containsKey("tripentry")) {
|
||||
List<Map<String, Object>> tripentryList = (List<Map<String, Object>>) temp1.get("tripentry");
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
for(Map<String, Object> tripentry : tripentryList) {
|
||||
amount = amount.add((BigDecimal)tripentry.get("triporiamount"));
|
||||
for (Map<String, Object> tripentry : tripentryList) {
|
||||
amount = amount.add((BigDecimal) tripentry.get("triporiamount"));
|
||||
tripentry.put("travelers", multitravelers);
|
||||
if(!tripentry.containsKey("tripexpenseitem")){
|
||||
Map<String, Object> tripexpenseitem = new HashMap<String, Object>();
|
||||
if (!tripentry.containsKey("tripexpenseitem")) {
|
||||
tempMap = new HashMap<String, Object>();
|
||||
//费用项目默认《差旅费》FYXM0015
|
||||
tripexpenseitem.put("number", "FYXM0015");
|
||||
tripentry.put("tripexpenseitem", tripexpenseitem);
|
||||
tempMap.put("number", "FYXM0015");
|
||||
tripentry.put("tripexpenseitem", tempMap);
|
||||
//交通工具默认《其它工具》 [1:飞机, 2:火车, 3:汽车, 4:轮船, 5:其他工具]
|
||||
tripentry.put("vehicles", "5");
|
||||
}
|
||||
|
@ -30,14 +59,25 @@ public class SaveTripBaseBillApiSavePlugin implements ApiSavePlugin {
|
|||
temp1.put("amount", amount);
|
||||
temp1.put("approveamount", amount);
|
||||
}
|
||||
if(!temp1.containsKey("triptype")){
|
||||
Map<String, Object> triptype = new HashMap<String, Object>();
|
||||
if (!temp1.containsKey("triptype")) {
|
||||
tempMap = new HashMap<String, Object>();
|
||||
//出差类型默认值《普通出差》001
|
||||
triptype.put("number", "001");
|
||||
temp1.put("triptype", triptype);
|
||||
tempMap.put("number", "001");
|
||||
temp1.put("triptype", tempMap);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue