|
|
@@ -2,9 +2,14 @@ package nckd.jxccl.swc.init.plugin.form;
|
|
|
|
|
|
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.datamodel.events.BizDataEventArgs;
|
|
|
import kd.bos.entity.param.CustomParam;
|
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
|
+import kd.bos.form.events.PreOpenFormEventArgs;
|
|
|
import kd.bos.form.operate.FormOperate;
|
|
|
import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
import kd.bos.logging.Log;
|
|
|
@@ -46,9 +51,11 @@ public class PendingSalaryAdjListPlugin extends AbstractListPlugin implements Pl
|
|
|
private static Log logger = LogFactory.getLog(PendingSalaryAdjListPlugin.class);
|
|
|
|
|
|
private DynamicObjectCollection salaryTypeDyns = null;
|
|
|
+ private DynamicObject salaryRankDyn = null;
|
|
|
+
|
|
|
@Override
|
|
|
- public void initialize() {
|
|
|
- super.initialize();
|
|
|
+ public void createNewData(BizDataEventArgs e) {
|
|
|
+ super.createNewData(e);
|
|
|
/**
|
|
|
* 获取 公共自定义参数 PENDSALARYADJ_DAYS
|
|
|
*/
|
|
|
@@ -58,21 +65,28 @@ public class PendingSalaryAdjListPlugin extends AbstractListPlugin implements Pl
|
|
|
String pendsalaryadjDays = cusTomMap.get("PENDSALARYADJ_DAYS");
|
|
|
days = Integer.parseInt(pendsalaryadjDays);
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取 定调薪类型
|
|
|
+ */
|
|
|
ArrayList<String> salaryTypeList = new ArrayList<>();
|
|
|
salaryTypeList.add("tiaozhengtiaoxin"); //岗位调整调薪
|
|
|
salaryTypeList.add("100009"); //入职定薪新
|
|
|
QFilter qFilter11 = new QFilter("number", QCP.in, salaryTypeList);
|
|
|
salaryTypeDyns = QueryServiceHelper.query("hsbs_salaryadjustrsn","id,number,name",new QFilter[]{qFilter11},"number");
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取入职时的薪档
|
|
|
+ */
|
|
|
+ QFilter qFilter12 = new QFilter("number", QCP.equals, "01");
|
|
|
+ salaryRankDyn = QueryServiceHelper.queryOne("hsbs_salaryrank","id,number,name",new QFilter[]{qFilter12});
|
|
|
+
|
|
|
//加载入职单与调动单的数据
|
|
|
getAdjustBillData();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void beforeBindData(EventObject e) {
|
|
|
super.beforeBindData(e);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -101,12 +115,50 @@ public class PendingSalaryAdjListPlugin extends AbstractListPlugin implements Pl
|
|
|
case "flag_adj":
|
|
|
break;
|
|
|
case "flag_ignore":
|
|
|
+ setBillStatus("F",key);
|
|
|
break;
|
|
|
case "cleanflag":
|
|
|
+ setBillStatus("A",key);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置单据状态
|
|
|
+ * @param billStatus
|
|
|
+ * A 待处理
|
|
|
+ * D 处理中
|
|
|
+ * C 已处理
|
|
|
+ * F 已忽略
|
|
|
+ */
|
|
|
+ public void setBillStatus(String billStatus,String operateKey) {
|
|
|
+ StringBuffer errorInfo = new StringBuffer();
|
|
|
+ ListSelectedRowCollection selectedRows = this.getSelectedRows();
|
|
|
+ MainEntityType entityType= EntityMetadataCache.getDataEntityType(entityName);
|
|
|
+ DynamicObject[] billDyns = BusinessDataServiceHelper.load(selectedRows.getPrimaryKeyValues(), entityType);
|
|
|
+ for (DynamicObject billDyn : billDyns){
|
|
|
+ String currbillstatus = billDyn.getString("billstatus");
|
|
|
+ String billno = billDyn.getString("billno");
|
|
|
+ if(operateKey.equals("flag_ignore") && !currbillstatus.equals("A")){
|
|
|
+ errorInfo.append(billno + ",单据状态不是待处理,请重新选择单据!");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(operateKey.equals("cleanflag") && !currbillstatus.equals("F")){
|
|
|
+ errorInfo.append(billno + ",单据状态不是已忽略,请重新选择单据!");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ billDyn.set("billstatus", billStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errorInfo.length() > 0) {
|
|
|
+ this.getView().showErrorNotification(errorInfo.toString());
|
|
|
+ }else{
|
|
|
+ Object[] update = SaveServiceHelper.save(billDyns);
|
|
|
+ this.getView().showSuccessNotification(update.length + "条,操作成功", 3000);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取入职单与调动单的数据
|
|
|
*/
|
|
|
@@ -166,18 +218,80 @@ public class PendingSalaryAdjListPlugin extends AbstractListPlugin implements Pl
|
|
|
dyn.set("nckd_salaryadjus", salaryTypeDyns.get(0).getLong("id")); //定调薪类型
|
|
|
dyn.set("nckd_newhradminorg", onhasonbrdDyn.getLong("ba_po_adminorg")); //部门
|
|
|
dyn.set("nckd_newposition", onhasonbrdDyn.getLong("ba_po_position.id")); //岗位
|
|
|
- dyn.set("nckd_newjoblevel", onhasonbrdDyn.getLong("ajoblevel.id")); //职级
|
|
|
dyn.set("nckd_newjobseqhr", onhasonbrdDyn.getLong("ba_po_job.jobseq.id")); //职位序列
|
|
|
+ dyn.set("nckd_newsalaryrank", salaryRankDyn.getLong("id"));
|
|
|
onhasonbrdCount++;
|
|
|
billDynList.add(dyn);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询调动单
|
|
|
+ */
|
|
|
+ String selectField1 = "id,billno,b_effectivedate,ba_em_tid,ba_em_empnumber,bb_po_position.id,aposition.id,bb_po_adminorg.id,aorg.id,bb_po_job.jobseq.id,ajob.jobseq.id";
|
|
|
+ QFilter qFilter12 = new QFilter("billstatus", QCP.equals, "C"); // 单据状态 = 已审核
|
|
|
+ QFilter qFilter13 = new QFilter("b_effectivedate", QCP.large_equals, daysAgo); //实际调动日期
|
|
|
+
|
|
|
+ DynamicObjectCollection transferDyns = QueryServiceHelper.query(transferEntityName, selectField1,new QFilter[]{qFilter12,qFilter13});
|
|
|
+
|
|
|
+ Map<Long, DynamicObject> transferMap = (Map)transferDyns.stream().collect(Collectors.toMap((obj) -> {
|
|
|
+ return obj.getLong("id");
|
|
|
+ }, (obj) -> {
|
|
|
+ return obj;
|
|
|
+ }, (k1, k2) -> {
|
|
|
+ return k1;
|
|
|
+ }));
|
|
|
+ List<Long> transferIDs = transferMap.keySet().stream().collect(Collectors.toList());
|
|
|
+
|
|
|
+ QFilter qFilter15 = new QFilter("nckd_billid", QCP.in, transferIDs);
|
|
|
+ List<Object> transferlistIDs = QueryServiceHelper.queryPrimaryKeys(entityName,new QFilter[]{qFilter15}, null, Integer.MAX_VALUE);
|
|
|
+ DynamicObject billDynType = BusinessDataServiceHelper.newDynamicObject(entityName);
|
|
|
+ DynamicObject[] billDyns1 = BusinessDataServiceHelper.load(transferlistIDs.toArray(),billDynType.getDynamicObjectType());
|
|
|
+
|
|
|
+ int transferCount = 0;
|
|
|
+ Map<Long, DynamicObject> billMap1 =
|
|
|
+ Arrays.stream(billDyns1)
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ detail -> detail.getLong("nckd_billid"),
|
|
|
+ detail -> detail, // 整个 DynamicObject 作为 value
|
|
|
+ (existing, replacement) -> existing // 保留前面的值
|
|
|
+ ));
|
|
|
+
|
|
|
+ for(DynamicObject transferDyn: transferDyns){
|
|
|
+ DynamicObject billDyn2 = billMap1.get(transferDyn.getLong("id"));
|
|
|
+ if(billDyn2 != null) continue;
|
|
|
+ DynamicObject dyn = BusinessDataServiceHelper.newDynamicObject(entityName);
|
|
|
+ dyn.set("billno", transferDyn.getString("billno"));
|
|
|
+ dyn.set("nckd_billid", transferDyn.getLong("id"));
|
|
|
+ dyn.set("nckd_billtype", "调动单");
|
|
|
+ dyn.set("billstatus", "A"); ///待处理
|
|
|
+ dyn.set("nckd_employeefield", transferDyn.getLong("ba_em_tid"));
|
|
|
+ dyn.set("nckd_changedate", transferDyn.getDate("b_effectivedate"));
|
|
|
+ dyn.set("nckd_salaryadjus", salaryTypeDyns.get(1).getLong("id")); //定调薪类型
|
|
|
+ /**
|
|
|
+ * 调动前
|
|
|
+ */
|
|
|
+ dyn.set("nckd_oldhradminorg", transferDyn.getLong("bb_po_adminorg.id")); //部门
|
|
|
+ dyn.set("nckd_oldposition", transferDyn.getLong("bb_po_position.id")); //岗位
|
|
|
+ dyn.set("nckd_oldjobseqhr", transferDyn.getLong("bb_po_job.jobseq.id")); //职位序列
|
|
|
+ dyn.set("nckd_oldsalaryrank", salaryRankDyn.getLong("id")); //薪档
|
|
|
+ /**
|
|
|
+ * 调动后
|
|
|
+ */
|
|
|
+ dyn.set("nckd_newhradminorg", transferDyn.getLong("aorg.id")); //部门
|
|
|
+ dyn.set("nckd_newposition", transferDyn.getLong("aposition.id")); //岗位
|
|
|
+ dyn.set("nckd_newjobseqhr", transferDyn.getLong("ajob.jobseq.id")); //职位序列
|
|
|
+ dyn.set("nckd_newsalaryrank", salaryRankDyn.getLong("id")); //薪档
|
|
|
+ transferCount++;
|
|
|
+ billDynList.add(dyn);
|
|
|
+ }
|
|
|
+
|
|
|
int length = 0;
|
|
|
if(billDynList.size() != 0) {
|
|
|
//保存
|
|
|
Object[] update = SaveServiceHelper.save(billDynList.toArray(new DynamicObject[0]));
|
|
|
length = update.length;
|
|
|
- this.getView().showSuccessNotification("成功导入,"+length+"条数据,其中入职单"+onhasonbrdCount+"条,",3000); // 成功类型
|
|
|
+ this.getView().showSuccessNotification("成功导入,"+length+"条数据,其中入职单"+onhasonbrdCount+"条,调动单"+transferCount+"条",4000); // 成功类型
|
|
|
}
|
|
|
|
|
|
}
|