|
|
@@ -27,6 +27,7 @@ import nckd.jxccl.base.swc.helper.SWCHelper;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 员工薪酬查询 WEB 动态表单插件
|
|
|
@@ -51,7 +52,9 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
|
|
|
Map<String, String> itemNameMap = new LinkedHashMap<>();
|
|
|
Map<String, BigDecimal> calItemAmtMap = new HashMap<>();
|
|
|
- Map<String, Map<String, BigDecimal>> calItemAmtMapByPeriod = new HashMap<>();
|
|
|
+ Map<Long, Map<String, BigDecimal>> calItemAmtMapByTask = new HashMap<>();
|
|
|
+ Map<Long, Map<String, String>> calItemStrMapByTask = new HashMap<>();
|
|
|
+ Map<Long, DynamicObject> calPersonIdMap = new HashMap<>();
|
|
|
|
|
|
private static final String CTL_DATAGRID = "nckd_datagridap";
|
|
|
|
|
|
@@ -68,48 +71,19 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
* 没有员工信息时,返回常量,用于测试
|
|
|
*/
|
|
|
KEY_EMPID = 2313784485549715456L;
|
|
|
- // this.getView().showMessage("未找到员工!");
|
|
|
- // return;
|
|
|
+
|
|
|
}else {
|
|
|
KEY_EMPID = personUserDyn.getLong("employee.id");
|
|
|
}
|
|
|
|
|
|
- if(!this.getModel().isDataLoaded()) {
|
|
|
-
|
|
|
- //KEY_STARTDATE = (Date) this.getModel().getValue(KEY_CTL_STARTDATE);
|
|
|
- //KEY_ENDDATE = (Date) this.getModel().getValue(KEY_CTL_ENDDATE);
|
|
|
- //KEY_TYPE = (String) this.getModel().getValue("nckd_type");
|
|
|
-
|
|
|
- showData();
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void afterCreateNewData(EventObject e) {
|
|
|
- super.afterCreateNewData(e);
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(new Date());
|
|
|
- calendar.add(Calendar.MONTH, -1);
|
|
|
- calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
- Date lastMonthDate = calendar.getTime();
|
|
|
- KEY_STARTDATE = lastMonthDate;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void beforeBindData(EventObject e) {
|
|
|
super.beforeBindData(e);
|
|
|
-
|
|
|
this.getModel().setValue(KEY_CTL_STARTDATE, KEY_STARTDATE);
|
|
|
-
|
|
|
this.getModel().setValue(KEY_CTL_ENDDATE, KEY_ENDDATE);
|
|
|
-
|
|
|
Long userId = UserServiceHelper.getCurrentUserId();
|
|
|
this.getModel().setValue("nckd_user", userId);
|
|
|
|
|
|
@@ -121,7 +95,10 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 注册监听事件
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@Override
|
|
|
public void registerListener(EventObject event) {
|
|
|
registerDataGridListener();
|
|
|
@@ -129,6 +106,9 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
this.addClickListeners("nckd_query");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过事件监听,注册数据表格监听事件
|
|
|
+ */
|
|
|
private void registerDataGridListener() {
|
|
|
DataGrid dataGrid = this.getControl(CTL_DATAGRID);
|
|
|
// 注册创建列监听事件
|
|
|
@@ -179,12 +159,14 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<Long> calPersonIds = SWCHelper.queryCalPersonList(KEY_EMPID);
|
|
|
- if(calPersonIds == null && calPersonIds.size() == 0) {
|
|
|
+ calPersonIdMap = SWCHelper.queryCalPersonList(KEY_EMPID);
|
|
|
+ if(calPersonIdMap == null && calPersonIdMap.size() <= 0) {
|
|
|
this.getView().showMessage("未找到员工!");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ //将Map转换为List
|
|
|
+ List<Long> calPersonIds = calPersonIdMap.keySet().stream().collect(Collectors.toList());
|
|
|
|
|
|
Label label = this.getView().getControl(KEY_LAB_EMP_NAME);
|
|
|
label.setText(employeeDyn.getString("employee.name"));
|
|
|
@@ -205,7 +187,7 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
DynamicObjectCollection calTableDyns = SWCHelper.querySalaryList(calPersonIds, startdate, enddate, type) ;
|
|
|
calItemAmtMap = getCalItemAmt(calTableDyns);
|
|
|
itemNameMap = getItemName(calTableDyns);
|
|
|
- calItemAmtMapByPeriod = getCalItemAmtByPeriod(calTableDyns);
|
|
|
+ getCalItemAmtByPeriod(calTableDyns);
|
|
|
|
|
|
if(calItemAmtMap != null && calItemAmtMap.size() > 0 && itemNameMap != null && !itemNameMap.isEmpty()){
|
|
|
DecimalFormat df = new DecimalFormat("#,##0.00");
|
|
|
@@ -270,10 +252,10 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
* @param calTableDyns 薪酬数据集合
|
|
|
* @return Map<period, Map<itemnumber, amount>> 嵌套Map结构
|
|
|
*/
|
|
|
- public Map<String, Map<String, BigDecimal>> getCalItemAmtByPeriod(DynamicObjectCollection calTableDyns) {
|
|
|
+ public void getCalItemAmtByPeriod(DynamicObjectCollection calTableDyns) {
|
|
|
|
|
|
/**
|
|
|
- * 排序
|
|
|
+ * 按日期排序
|
|
|
*/
|
|
|
Collections.sort(calTableDyns , new Comparator<DynamicObject>(){
|
|
|
@Override
|
|
|
@@ -283,11 +265,13 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
});
|
|
|
|
|
|
// 按 period 分组,每个 period 再按 salaryitem.number 分组汇总金额
|
|
|
- Map<String, Map<String, BigDecimal>> result = new LinkedHashMap<>();
|
|
|
+ Map<Long, Map<String, BigDecimal>> resultAmt = new LinkedHashMap<>();
|
|
|
+ Map<Long, Map<String, String>> resultStr = new LinkedHashMap<>();
|
|
|
|
|
|
for (DynamicObject item : calTableDyns) {
|
|
|
Date bizPeriod = item.getDate("bizdate");
|
|
|
String period = DateUtil.format(bizPeriod, "yyyy-MM");
|
|
|
+ Long caltaskId = item.getLong("caltask.id");
|
|
|
String salaryItemNumber = item.getString("hsas_caltableentry.salaryitem.number");
|
|
|
BigDecimal amount = item.getBigDecimal("hsas_caltableentry.calamountvalue");
|
|
|
|
|
|
@@ -299,15 +283,51 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
|
|
|
if (period != null && salaryItemNumber != null) {
|
|
|
// 获取当前 period 的子 map,如果不存在则创建新的
|
|
|
- Map<String, BigDecimal> periodMap = result.computeIfAbsent(period, k -> new HashMap<>());
|
|
|
+ Map<String, BigDecimal> periodMap = resultAmt.computeIfAbsent(caltaskId, k -> new HashMap<>());
|
|
|
// 在 period 子 map 中累加 salaryItemNumber 对应的金额
|
|
|
periodMap.put(salaryItemNumber, periodMap.getOrDefault(salaryItemNumber, BigDecimal.ZERO).add(amount != null ? amount : BigDecimal.ZERO));
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> resultMap = resultStr.computeIfAbsent(caltaskId, k -> new HashMap<>());
|
|
|
+ resultMap.put("nckd_org", item.getString("caltask.org.name"));
|
|
|
+ resultMap.put("nckd_calcount", item.getString("caltask.calcount"));
|
|
|
+ resultMap.put("nckd_rulename", item.getString("caltask.calrule.name"));
|
|
|
+
|
|
|
+ if(calPersonIdMap != null && !calPersonIdMap.isEmpty()){
|
|
|
+ Long calperson = item.getLong("calpersonid");
|
|
|
+ DynamicObject dyn = calPersonIdMap.get(calperson);
|
|
|
+ resultMap.put("nckd_period", period);
|
|
|
+ resultMap.put("calperson", calperson.toString());
|
|
|
+ resultMap.put("nckd_position", dyn.getString("empposorgrelsndet.position.name"));
|
|
|
+ StringBuilder orgName = new StringBuilder();
|
|
|
+ if(dyn.getString("adminorg.nckd_secondorg.name") != null){
|
|
|
+ orgName.append(dyn.getString("adminorg.nckd_secondorg.name"));
|
|
|
+ }
|
|
|
+ if(dyn.getString("adminorg.nckd_thirdorg.name") != null){
|
|
|
+ orgName.append( "_");
|
|
|
+ orgName.append(dyn.getString("adminorg.nckd_thirdorg.name"));
|
|
|
+ }
|
|
|
+ if(dyn.getString("adminorg.nckd_fourthorg.name") != null) {
|
|
|
+ orgName.append( "_");
|
|
|
+ orgName.append(dyn.getString("adminorg.nckd_fourthorg.name"));
|
|
|
+ }
|
|
|
+ if(dyn.getString("adminorg.nckd_fifthorg.name") != null){
|
|
|
+ orgName.append( "_");
|
|
|
+ orgName.append(dyn.getString("adminorg.nckd_fifthorg.name"));
|
|
|
+ }
|
|
|
+ if(dyn.getString("adminorg.nckd_sixthorg.name") != null){
|
|
|
+ orgName.append( "_");
|
|
|
+ orgName.append(dyn.getString("adminorg.nckd_sixthorg.name"));
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap.put("nckd_calorg", orgName.toString());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return result.isEmpty() ? null : result;
|
|
|
- }
|
|
|
+ calItemAmtMapByTask = resultAmt.isEmpty() ? null : resultAmt;
|
|
|
+ calItemStrMapByTask = resultStr.isEmpty() ? null : resultStr;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 按 salaryitem.number 获取名称
|
|
|
@@ -376,22 +396,28 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
public void dataGridBindData(DataGridBindDataEvent e) {
|
|
|
List<Object> list = new ArrayList<>();
|
|
|
int index = 0;
|
|
|
- if(calItemAmtMapByPeriod != null && !calItemAmtMapByPeriod.isEmpty()) {
|
|
|
+ if(calItemAmtMapByTask != null && !calItemAmtMapByTask.isEmpty() && calItemStrMapByTask != null && !calItemStrMapByTask.isEmpty()) {
|
|
|
DataGridRowBuilder builder = e.getDataGridRowBuilder();
|
|
|
// 遍历每个周期
|
|
|
- for (Map.Entry<String, Map<String, BigDecimal>> periodEntry : calItemAmtMapByPeriod.entrySet()) {
|
|
|
- String period = periodEntry.getKey();
|
|
|
- Map<String, BigDecimal> itemAmountMap = periodEntry.getValue();
|
|
|
+ for (Map.Entry<Long, Map<String, BigDecimal>> taskEntry : calItemAmtMapByTask.entrySet()) {
|
|
|
+ Long taskID = taskEntry.getKey();
|
|
|
+ Map<String, BigDecimal> itemAmountMap = taskEntry.getValue();
|
|
|
|
|
|
+ Map<String, String> itemStrMap = calItemStrMapByTask.get( taskID);
|
|
|
// 为每个周期构建一行数据
|
|
|
DataGridRow row = builder.buildRow();
|
|
|
|
|
|
// 设置系统保留字段
|
|
|
row.setValue("rk", index); // rk必须存在且唯一不能重复
|
|
|
- row.setValue("seq", index + 1);
|
|
|
+ row.setValue("seq", taskID);
|
|
|
|
|
|
// 设置周期字段(假设用"period"字段表示)
|
|
|
- row.setValue("nckd_period", period);
|
|
|
+ row.setValue("nckd_period", itemStrMap.get("nckd_period"));
|
|
|
+ row.setValue("nckd_org", itemStrMap.get("nckd_org"));
|
|
|
+ row.setValue("nckd_calcount", itemStrMap.get("nckd_calcount"));
|
|
|
+ row.setValue("nckd_rulename", itemStrMap.get("nckd_rulename"));
|
|
|
+ row.setValue("nckd_position", itemStrMap.get("nckd_position"));
|
|
|
+ row.setValue("nckd_calorg", itemStrMap.get("nckd_calorg"));
|
|
|
|
|
|
// 遍历该项目的所有薪资项,按itemnumber设置列值
|
|
|
for (Map.Entry<String, BigDecimal> itemEntry : itemAmountMap.entrySet()) {
|
|
|
@@ -402,8 +428,6 @@ public class EmpSalaryQueryWebFormPlugin extends AbstractFormPlugin implements
|
|
|
row.setValue(itemNumber, amount);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
list.add(row.get());
|
|
|
index++;
|
|
|
|