|
|
@@ -0,0 +1,109 @@
|
|
|
+package nckd.jxccl.swc.init.plugin.operate;
|
|
|
+
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
+import kd.bos.entity.MainEntityType;
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
+import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
+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 kd.sdk.swc.hcdm.business.helper.HCDMApplyBillServiceHelper;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * hcdm_applybill 生成定调薪申请单,单据操作插件
|
|
|
+ * author: turborao
|
|
|
+ * date: 2025/11/24 9:05
|
|
|
+ */
|
|
|
+public class BuildApplyBillOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
+ super.beginOperationTransaction(e);
|
|
|
+ DynamicObject[] datas = e.getDataEntities();
|
|
|
+
|
|
|
+ Map<Long, DynamicObject> employeeMap =
|
|
|
+ Arrays.stream(datas)
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ detail -> detail.getLong("nckd_employeefield"),
|
|
|
+ detail -> detail, // 整个 DynamicObject 作为 value
|
|
|
+ (existing, replacement) -> existing // 保留前面的值
|
|
|
+ ));
|
|
|
+
|
|
|
+ List<Long> employeeIDs = employeeMap.keySet().stream().collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<String,Object> applyBill = new HashMap<>();
|
|
|
+ applyBill.put("billname","员工待定调薪清单-生成");
|
|
|
+
|
|
|
+ Long orgId = RequestContext.get().getOrgId();
|
|
|
+
|
|
|
+ applyBill.put("org",orgId);
|
|
|
+ applyBill.put("billcountry", 1000001L); //国家
|
|
|
+ applyBill.put("salaryadjrsn", 2352340656979984384L); //定调薪类型
|
|
|
+ applyBill.put("billcurrency", 1L); //默认币种
|
|
|
+ applyBill.put("exchangeratedate", new Date()); //汇率日期
|
|
|
+ applyBill.put("exctable", 2321965096026258432L); //汇率表
|
|
|
+ applyBill.put("effectivedate", new Date()); //默认生效日期
|
|
|
+ applyBill.put("isdraft", "1"); //草稿状态
|
|
|
+ applyBill.put("datasource", "2"); //申请单数据来源 //1:手工新增 2:接口写入
|
|
|
+
|
|
|
+ Map<Long, DynamicObject> salaryfileMap = getSalaryFileInfo(employeeIDs);
|
|
|
+
|
|
|
+ List<Map<String,Object>> applyBillEntryData = new ArrayList<>();
|
|
|
+ for (DynamicObject data : datas) {
|
|
|
+ Map<String,Object> applyBillEntry = new HashMap<>();
|
|
|
+ Long employeeId = data.getLong("nckd_employeefield");
|
|
|
+ DynamicObject salaryfile = salaryfileMap.get(employeeId);
|
|
|
+ applyBillEntry.put("adjfile", salaryfile.getLong("boid"));
|
|
|
+ applyBillEntry.put("employee", employeeId);
|
|
|
+ applyBillEntry.put("hcdmorg", salaryfile.getLong("org.id")); //薪酬管理组织
|
|
|
+ applyBillEntry.put("country", salaryfile.getLong("country.id")); //薪酬管理属地
|
|
|
+ applyBillEntry.put("salarystructure", salaryfile.getLong("salarystructure.id")); //薪酬结构
|
|
|
+ applyBillEntry.put("stdscmv", salaryfile.getLong("stdscm.id")); //
|
|
|
+ applyBillEntry.put("empgroup", salaryfile.getLong("empgroup.id")); //定调薪档案分组
|
|
|
+ applyBillEntry.put("nckd_postgrade", salaryfile.getLong("position.nckd_postgrade.id")); //岗级
|
|
|
+ applyBillEntry.put("position", data.getLong("nckd_newposition"));
|
|
|
+ applyBillEntry.put("salaryrank", data.getLong("nckd_newsalaryrank"));
|
|
|
+ applyBillEntry.put("adminorg", data.getLong("nckd_newhradminorg"));
|
|
|
+ applyBillEntryData.add(applyBillEntry);
|
|
|
+ }
|
|
|
+ applyBill.put("applybillent", applyBillEntryData);
|
|
|
+ Map<String, Object> result = HCDMApplyBillServiceHelper.saveDraftApplyBill(applyBill);
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取员工定调薪档案 hcdm_adjfileinfo
|
|
|
+ */
|
|
|
+ public Map<Long, DynamicObject> getSalaryFileInfo(List<Long> employeeIDs){
|
|
|
+
|
|
|
+ QFilter qFilter = new QFilter("employee.id", QCP.in, employeeIDs);
|
|
|
+ QFilter qFilter1 = new QFilter("iscurrentversion", QCP.equals, "1"); // 启用
|
|
|
+ QFilter qFilter2 = new QFilter("datastatus", QCP.equals, "1"); // 启用
|
|
|
+ String selectField = "id,boid,number,employee.id,org.id,country.id,salarystructure.id,stdscm.id,empgroup.id,position.nckd_postgrade.id";
|
|
|
+ DynamicObjectCollection employeesFiles = QueryServiceHelper.query("hcdm_adjfileinfo", selectField, new QFilter[]{qFilter,qFilter1,qFilter2});
|
|
|
+
|
|
|
+ Map<Long, DynamicObject> salaryfileMap = (Map)employeesFiles.stream().collect(Collectors.toMap((obj) -> {
|
|
|
+ return obj.getLong("employee.id");
|
|
|
+ }, (obj) -> {
|
|
|
+ return obj;
|
|
|
+ }, (k1, k2) -> {
|
|
|
+ return k1;
|
|
|
+ }));
|
|
|
+
|
|
|
+ return salaryfileMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|