|
@@ -2,6 +2,7 @@ package nckd.jimin.jyyy.hr.swc.hcdm.formplugin.web;
|
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.utils.ObjectUtils;
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
@@ -17,6 +18,9 @@ import kd.tdc.tjga.business.task.ScheduleExecutor;
|
|
|
import nckd.jimin.jyyy.hr.swc.hsas.formplugin.web.helper.AdjSalFileHelper;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static nckd.jimin.jyyy.hr.swc.hsas.formplugin.web.helper.AdjSalFileHelper.matchStdTableForBill;
|
|
|
|
|
|
/**
|
|
|
* 批量职等调整单生效插件
|
|
@@ -33,48 +37,74 @@ public class AdjustJobBillEffectOp extends AbstractOperationServicePlugIn implem
|
|
|
super.endOperationTransaction(e);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 职级/定调薪信息调整
|
|
|
+ * 如果表头是否调级 = 否,则只调整薪酬信息
|
|
|
+ * 如果表头是否调级 = 是,则职级职等及薪酬信息都要调整,且薪酬信息调整要按照本单调整后的职级为准;
|
|
|
+ * @param e
|
|
|
+ */
|
|
|
@Override
|
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
super.afterExecuteOperationTransaction(e);
|
|
|
-
|
|
|
+ boolean isAdjustJob = false;
|
|
|
+ Map<String, DynamicObject> jobMap = new HashMap();
|
|
|
DynamicObject[] bills = e.getDataEntities();
|
|
|
for (DynamicObject bill : bills) {
|
|
|
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(), bill.getDataEntityType().getName());
|
|
|
+ //是否调级
|
|
|
+ String isAdjustJobStr = bill.getString("nckd_isadjustjob");
|
|
|
+ //如果是否调级 = 是,处理下职级调整分录的数据Map,key = 工号, value = 分录Dyn
|
|
|
+ if("1".equals(isAdjustJobStr)) {
|
|
|
+ isAdjustJob = true;
|
|
|
+ DynamicObjectCollection jobEntryCols = bill.getDynamicObjectCollection("changeentry");
|
|
|
+ jobMap = (Map) jobEntryCols.stream().collect(Collectors.toMap((dyx) -> {
|
|
|
+ return dyx.getString("number");
|
|
|
+ }, (dyx) -> {
|
|
|
+ return dyx;
|
|
|
+ }, (key1, key2) -> {
|
|
|
+ return key2;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
DynamicObjectCollection entryCols = bill.getDynamicObjectCollection("nckd_entryentity");
|
|
|
if(entryCols.size() > 0) {
|
|
|
- int index = 1;
|
|
|
+ int index = 0;
|
|
|
int successCount = 0;
|
|
|
for(DynamicObject entry : entryCols) {
|
|
|
if(entry.getString("nckd_salsyncstatus").equals("1"))
|
|
|
continue;
|
|
|
+ //需要调整的条数
|
|
|
+ index++;
|
|
|
//定调薪信息
|
|
|
Long adjRecordId = entry.getLong("nckd_adjrecord.id");
|
|
|
DynamicObject adjRecord = BusinessDataServiceHelper.loadSingle(adjRecordId, "hcdm_salaryadjrecord");
|
|
|
//定调薪档案
|
|
|
Long adjFileId = entry.getLong("nckd_adjfile.id");
|
|
|
//定调薪人员信息
|
|
|
-
|
|
|
Long relPersonId = adjRecord.getLong("relpersonid");
|
|
|
DynamicObject relPerson = BusinessDataServiceHelper.loadSingle(relPersonId, "hcdm_decadjrelperson");
|
|
|
- List<Map<String, Object>> list = buildContent(bill, entry, adjRecord, relPerson);
|
|
|
- Map<String, Object> returnMap = helper.saveDecAdjRecord(list);
|
|
|
- if(!Boolean.valueOf(returnMap.get("success").toString())) {
|
|
|
- List dataList = (List) returnMap.get("data");
|
|
|
- Map dataMap = (Map) dataList.get(0);
|
|
|
- entry.set("nckd_synclog",dataMap.get("errormsg").toString());
|
|
|
- //bill.set("billstatus", "B");
|
|
|
- //SaveServiceHelper.save(new DynamicObject[]{bill});
|
|
|
- //throw new KDBizException("第"+ index + "行同步定调薪信息出错:" + dataMap.get("errormsg").toString());
|
|
|
- //
|
|
|
+ Map map = buildContent(bill, entry, adjRecord, relPerson, isAdjustJob, jobMap);
|
|
|
+ if(!Boolean.valueOf(map.get("success").toString())) {
|
|
|
+ entry.set("nckd_synclog", map.get("msg").toString());
|
|
|
}
|
|
|
else {
|
|
|
- successCount++;
|
|
|
- entry.set("nckd_salsyncstatus", "1");
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("data");
|
|
|
+ Map<String, Object> returnMap = helper.saveDecAdjRecord(list);
|
|
|
+ if (!Boolean.valueOf(returnMap.get("success").toString())) {
|
|
|
+ List dataList = (List) returnMap.get("data");
|
|
|
+ Map dataMap = (Map) dataList.get(0);
|
|
|
+ entry.set("nckd_synclog", dataMap.get("errormsg").toString());
|
|
|
+ } else {
|
|
|
+ //成功条数
|
|
|
+ successCount++;
|
|
|
+ entry.set("nckd_salsyncstatus", "1");
|
|
|
+ entry.set("nckd_synclog", null);
|
|
|
+ }
|
|
|
+ index++;
|
|
|
}
|
|
|
- index++;
|
|
|
}
|
|
|
|
|
|
- if(successCount != entryCols.size()) {
|
|
|
+ if(successCount != index) {
|
|
|
bill.set("billstatus", "B");
|
|
|
SaveServiceHelper.save(new DynamicObject[]{bill});
|
|
|
throw new KDBizException("定调薪信息出错,请查看薪酬调整明细同步薪酬日志");
|
|
@@ -99,7 +129,9 @@ public class AdjustJobBillEffectOp extends AbstractOperationServicePlugIn implem
|
|
|
* @param relPerson
|
|
|
* @return
|
|
|
*/
|
|
|
- public static List<Map<String, Object>> buildContent(DynamicObject bill, DynamicObject entry, DynamicObject adjRecord, DynamicObject relPerson) {
|
|
|
+ public static Map buildContent(DynamicObject bill, DynamicObject entry, DynamicObject adjRecord,
|
|
|
+ DynamicObject relPerson, boolean isAdjustJob, Map<String,DynamicObject> jobMap) {
|
|
|
+ Map returnMap = new HashMap();
|
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
Map info = new HashMap();
|
|
|
//数据模式 1-变更 2-禁用
|
|
@@ -118,8 +150,34 @@ public class AdjustJobBillEffectOp extends AbstractOperationServicePlugIn implem
|
|
|
info.put("standarditem", adjRecord.getLong("standarditem.id"));
|
|
|
info.put("frequency", adjRecord.getLong("frequency.id"));
|
|
|
info.put("nckd_fxxs", adjRecord.getBigDecimal("nckd_fxxs"));
|
|
|
- info.put("grade", adjRecord.getLong("grade.id"));
|
|
|
- info.put("rank", adjRecord.getLong("rank.id"));
|
|
|
+ String personNo = entry.getString("nckd_salnumber");
|
|
|
+ DynamicObject jobEntry = jobMap.get(personNo);
|
|
|
+ //如果是否调级 = 是,则取职级调整分录中的调整后职级职等,如果按工号没找到数据则按定调薪信息的职级职等
|
|
|
+ if(isAdjustJob && jobMap != null) {
|
|
|
+ if(ObjectUtils.isEmpty(jobEntry)) {
|
|
|
+ info.put("grade", adjRecord.getLong("grade.id"));
|
|
|
+ info.put("rank", adjRecord.getLong("rank.id"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Long jobLevelId = jobEntry.getLong("joblevel.id");
|
|
|
+ Map matchMap = matchStdTableForBill(relPerson.getLong("stdscm.boid"),
|
|
|
+ relPerson.getLong("salaystructure.id"), adjRecord.getLong("standarditem.id"), jobLevelId);
|
|
|
+ //判断是否匹配成功
|
|
|
+ if(Boolean.valueOf(matchMap.get("success").toString())) {
|
|
|
+ info.put("grade", matchMap.get("grade"));
|
|
|
+ info.put("rank", matchMap.get("rank"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ returnMap.put("success", false);
|
|
|
+ returnMap.put("msg", matchMap.get("msg").toString());
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ info.put("grade", adjRecord.getLong("grade.id"));
|
|
|
+ info.put("rank", adjRecord.getLong("rank.id"));
|
|
|
+ }
|
|
|
info.put("amount", entry.getBigDecimal("nckd_amount"));
|
|
|
|
|
|
//人员相关信息
|
|
@@ -131,13 +189,22 @@ public class AdjustJobBillEffectOp extends AbstractOperationServicePlugIn implem
|
|
|
relperson_data.put("assoadminorg", relPerson.getLong("assoadminorg.id"));
|
|
|
relperson_data.put("depemp", relPerson.getLong("depemp.id"));
|
|
|
relperson_data.put("country", 1000001L);
|
|
|
- relperson_data.put("joblevel",relPerson.getLong("joblevel.id"));
|
|
|
+ if(isAdjustJob && jobMap != null && !ObjectUtils.isEmpty(jobEntry)) {
|
|
|
+ relperson_data.put("joblevel", jobEntry.getLong("joblevel.id"));
|
|
|
+ relperson_data.put("jobgrade", jobEntry.getLong("jobgrade.id"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ relperson_data.put("joblevel", relPerson.getLong("joblevel.id"));
|
|
|
+ relperson_data.put("jobgrade", relPerson.getLong("jobgrade.id"));
|
|
|
+ }
|
|
|
relperson_data.put("salaystructure", relPerson.getLong("salaystructure.id"));
|
|
|
relperson_data.put("stdscm", relPerson.getLong("stdscm.id"));
|
|
|
relperson_data.put("empgroup", 1090L);
|
|
|
info.put("relperson_data", relperson_data);
|
|
|
list.add(info);
|
|
|
- return list;
|
|
|
+ returnMap.put("data", list);
|
|
|
+ returnMap.put("success", true);
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
|
|
|
}
|