|
|
@@ -1,8 +1,29 @@
|
|
|
package uzi9.uzi9q.opmcepaq.epaq.plugin.form.zd;
|
|
|
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.entity.OrmLocaleValue;
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRow;
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|
|
+import kd.bos.entity.operate.result.OperationResult;
|
|
|
+import kd.bos.form.*;
|
|
|
+import kd.bos.form.control.Control;
|
|
|
+import kd.bos.form.control.events.ItemClickEvent;
|
|
|
+import kd.bos.form.events.ClosedCallBackEvent;
|
|
|
+import kd.bos.form.events.SetFilterEvent;
|
|
|
+import kd.bos.list.BillList;
|
|
|
+import kd.bos.list.ListShowParameter;
|
|
|
import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+
|
|
|
+import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.EventObject;
|
|
|
|
|
|
/**
|
|
|
@@ -11,13 +32,233 @@ import java.util.EventObject;
|
|
|
public class EvaluationObjectListPlugin extends AbstractListPlugin implements Plugin {
|
|
|
|
|
|
@Override
|
|
|
- public void afterBindData(EventObject e) {
|
|
|
- super.afterBindData(e);
|
|
|
+ public void setFilter(SetFilterEvent e) {
|
|
|
+ super.setFilter(e);
|
|
|
+ //添加过滤条件,只能看见当前考核下的评估对象
|
|
|
+ Object ActivityId = this.getView().getFormShowParameter().getCustomParam("ActivityId");
|
|
|
+ /*QFilter qFilter = new QFilter("uzi9_assessment_activity.id", QCP.equals, ActivityId);
|
|
|
+ e.getQFilters().add(qFilter);*/
|
|
|
+ e.setOrderBy("billno asc");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void itemClick(ItemClickEvent evt) {
|
|
|
+ super.itemClick(evt);
|
|
|
+ String itemKey = evt.getItemKey();
|
|
|
+ if (itemKey.equals("uzi9_new")) {
|
|
|
+ ListShowParameter parameter = new ListShowParameter();
|
|
|
+ //设置实体id
|
|
|
+ parameter.setBillFormId("bos_user");
|
|
|
+ //设置选择状态
|
|
|
+ parameter.setLookUp(true);
|
|
|
+ //设置展开
|
|
|
+ parameter.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
+ //设置模版id
|
|
|
+ parameter.setFormId("bos_usertreelistf7");
|
|
|
+ //设置回调
|
|
|
+ parameter.setCloseCallBack(new CloseCallBack(this, "add"));
|
|
|
+ // 设置展开宽度,高度
|
|
|
+ StyleCss styleCss = new StyleCss();
|
|
|
+ styleCss.setWidth("800");
|
|
|
+ styleCss.setHeight("500");
|
|
|
+ parameter.getOpenStyle().setInlineStyleCss(styleCss);
|
|
|
+ //跳转
|
|
|
+ getView().showForm(parameter);
|
|
|
+ }
|
|
|
+
|
|
|
+ //从其他考核活动进行新增
|
|
|
+ if (itemKey.equals("uzi9_pull")) {
|
|
|
+ ListShowParameter parameter = new ListShowParameter();
|
|
|
+ //设置实体id
|
|
|
+ parameter.setBillFormId("bos_user");
|
|
|
+ //设置选择状态
|
|
|
+ parameter.setLookUp(true);
|
|
|
+ //设置展开
|
|
|
+ parameter.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
+ //设置模版id
|
|
|
+ parameter.setFormId("uzi9_evaluation_pull");
|
|
|
+ //设置回调
|
|
|
+ parameter.setCloseCallBack(new CloseCallBack(this, "pull"));
|
|
|
+ // 设置展开宽度,高度
|
|
|
+ StyleCss styleCss = new StyleCss();
|
|
|
+ styleCss.setWidth("800");
|
|
|
+ styleCss.setHeight("500");
|
|
|
+ parameter.getOpenStyle().setInlineStyleCss(styleCss);
|
|
|
+ //跳转
|
|
|
+ getView().showForm(parameter);
|
|
|
+ }
|
|
|
+ //删除效验
|
|
|
+ if (itemKey.equals("uzi9_delete")) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
|
|
+ super.closedCallBack(closedCallBackEvent);
|
|
|
+ // 接收回调
|
|
|
+ //获取回调标识
|
|
|
+ String actionId = closedCallBackEvent.getActionId();
|
|
|
+ if (actionId.equals("add")) {
|
|
|
+ if (closedCallBackEvent.getReturnData() instanceof ListSelectedRowCollection) {
|
|
|
+ ListSelectedRowCollection selectCollections = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
|
|
+ ArrayList list = new ArrayList();
|
|
|
+ for (ListSelectedRow row : selectCollections) {
|
|
|
+ // list存储id
|
|
|
+ list.add(row.getPrimaryKeyValue());
|
|
|
+ }
|
|
|
+ // 构造QFilte
|
|
|
+ QFilter qFilter = new QFilter("id", QFilter.equals, list.get(0));
|
|
|
+ for (int i = 1; i < list.size(); i++) {
|
|
|
+ qFilter = qFilter.or(new QFilter("id", QFilter.equals, list.get(i)));
|
|
|
+ }
|
|
|
+ // 将选中的id对应的数据从数据库加载出来
|
|
|
+ DynamicObject[] load = BusinessDataServiceHelper.load("bos_user", "id,name,number,entryentity,startdate,entryentity.post,entryentity.dpt,entryentity.ispartjob", qFilter.toArray());
|
|
|
+ for (DynamicObject dynamicObject : load) {
|
|
|
+ //新增
|
|
|
+ userAddOne(dynamicObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (actionId.equals("pull")) {
|
|
|
+ if (closedCallBackEvent.getReturnData() instanceof ListSelectedRowCollection) {
|
|
|
+ ListSelectedRowCollection selectCollections = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
|
|
+ ArrayList list = new ArrayList();
|
|
|
+ for (ListSelectedRow row : selectCollections) {
|
|
|
+ // list存储id
|
|
|
+ list.add(row.getPrimaryKeyValue());
|
|
|
+ }
|
|
|
+ // 构造QFilte
|
|
|
+ QFilter qFilter = new QFilter("id", QFilter.equals, list.get(0));
|
|
|
+ for (int i = 1; i < list.size(); i++) {
|
|
|
+ qFilter = qFilter.or(new QFilter("id", QFilter.equals, list.get(i)));
|
|
|
+ }
|
|
|
+ // 将选中的id对应的数据从数据库加载出来
|
|
|
+ DynamicObject[] load = BusinessDataServiceHelper.load("bos_user", "id,name,number", qFilter.toArray());
|
|
|
+ //新增
|
|
|
+ userAddTwo(load);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加方法一(无论用什么方法一切的前提是拿到员工工号,无论是一个还是一群)
|
|
|
+ public void userAddOne(DynamicObject useradd) {
|
|
|
+ //获取用户工号
|
|
|
+ Object employeeId = useradd.get("number");
|
|
|
+ //判断条件是否有工号相同的参数
|
|
|
+ QFilter qFilter = new QFilter("uzi9_employeeid", QFilter.equals, employeeId);
|
|
|
+ //对评估对象表进行筛选
|
|
|
+ DynamicObject employeeIdCheck = BusinessDataServiceHelper.loadSingle("uzi9_evaluation_object", "uzi9_employeeid", new QFilter[]{qFilter});
|
|
|
+
|
|
|
+ //获取通过跳转传过来的活动id并查询对应的活动
|
|
|
Object activityId = this.getView().getFormShowParameter().getCustomParam("ActivityId");
|
|
|
- if (activityId == null) {
|
|
|
+ DynamicObject assessment = BusinessDataServiceHelper.loadSingle("uzi9_assessment_activity", "id", new QFilter[]{new QFilter("id", QFilter.equals, activityId)});
|
|
|
+
|
|
|
+ //判断是否为空
|
|
|
+ if (employeeIdCheck != null) {
|
|
|
+ this.getView().showErrorNotification("员工:" + useradd.get("name") + "已经加入了本考核活动或其他考核活动");
|
|
|
return;
|
|
|
}
|
|
|
- String string = activityId.toString();
|
|
|
- System.out.println(string);
|
|
|
+
|
|
|
+ DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("uzi9_evaluation_object");
|
|
|
+ //语言设置默认为zh_CN
|
|
|
+ Object name = getDefaultValue(useradd.get("name"));
|
|
|
+ //姓名
|
|
|
+ dynamicObject.set("name", name);
|
|
|
+ //工号
|
|
|
+ dynamicObject.set("uzi9_employeeid", useradd.get("number"));
|
|
|
+ DynamicObjectCollection entryentity = useradd.getDynamicObjectCollection("entryentity");
|
|
|
+ DynamicObject post = null;
|
|
|
+ DynamicObject dpt = null;
|
|
|
+ //部门分录遍历
|
|
|
+ for (DynamicObject entry : entryentity) {
|
|
|
+ boolean bl = (boolean) entry.get("ispartjob");
|
|
|
+ //获取不是兼职的组织和岗位
|
|
|
+ if (!bl) {
|
|
|
+ post = (DynamicObject) entry.get("post");
|
|
|
+ dpt = (DynamicObject) entry.get("dpt");
|
|
|
+ //岗位
|
|
|
+ if (post != null) {
|
|
|
+ dynamicObject.set("uzi9_position", post);
|
|
|
+ } else {
|
|
|
+ this.getView().showTipNotification(useradd.get("name") + ":没有设置岗位,拒绝新增");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //组织
|
|
|
+ if (dpt != null) {
|
|
|
+ dynamicObject.set("uzi9_orgfield", dpt);
|
|
|
+ } else {
|
|
|
+ this.getView().showTipNotification(useradd.get("name") + ":没有设置组织,拒绝新增");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*//组织
|
|
|
+ dynamicObject.set("uzi9_orgfield", useradd.get("组织标识"));
|
|
|
+ //岗位
|
|
|
+ dynamicObject.set("uzi9_position", useradd.get("岗位标识"));*/
|
|
|
+ //入职日期
|
|
|
+ dynamicObject.set("uzi9_date_joining", useradd.get("startdate"));
|
|
|
+ //考核进度(默认为:未开始 - 1)
|
|
|
+ dynamicObject.set("uzi9_progress", 1);
|
|
|
+ //uzi9_business_activities绩效业务活动,后续hr自行修改添加
|
|
|
+ //uzi9_activity_status绩效业务活动状态,后续hr自行修改添加
|
|
|
+ //考核活动
|
|
|
+ dynamicObject.set("uzi9_assessment_activity", assessment);
|
|
|
+ //使用状态
|
|
|
+ dynamicObject.set("enable", 1);
|
|
|
+ //数据状态
|
|
|
+ dynamicObject.set("status", "A");
|
|
|
+ OperationResult result = SaveServiceHelper.saveOperate("uzi9_evaluation_object", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
|
|
+ this.getView().updateView();
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ this.getView().showSuccessNotification("新增数据成功");
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ } else {
|
|
|
+ this.getView().showErrorNotification("新增数据失败");
|
|
|
+ this.getView().invokeOperation("refresh");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ //添加方法二(沟通bos_user中获取工号,修改评估对象的考核活动进行新增)
|
|
|
+ public void userAddTwo(DynamicObject[] useradds) {
|
|
|
+ //获取活动id活动活动对象
|
|
|
+ for (DynamicObject useradd : useradds) {
|
|
|
+ Object number = useradd.get("number");
|
|
|
+ //通过工号获取评估对象
|
|
|
+ DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("uzi9_evaluation_object", "id,uzi9_assessment_activity,name", new QFilter[]{new QFilter("uzi9_employeeid", QFilter.equals, number)});
|
|
|
+ if (dynamicObject == null) {
|
|
|
+ this.getView().showTipNotification("当前员工没有加入任何考核活动,请通过新增进行添加");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //获取当下的考核活动id
|
|
|
+ Object activityId = this.getView().getFormShowParameter().getCustomParam("ActivityId");
|
|
|
+ //查询考核活动
|
|
|
+ DynamicObject assessment = BusinessDataServiceHelper.loadSingle("uzi9_assessment_activity", "id", new QFilter[]{new QFilter("id", QFilter.equals, activityId)});
|
|
|
+ //修改评价对象的考核活动
|
|
|
+ dynamicObject.set("uzi9_assessment_activity", assessment);
|
|
|
+ //更新数据
|
|
|
+ OperationResult result = SaveServiceHelper.saveOperate("uzi9_evaluation_object", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ this.getView().showSuccessNotification(dynamicObject.get("name") + "转移成功");
|
|
|
+ } else {
|
|
|
+ this.getView().invokeOperation(dynamicObject.get("name") + "转移失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //语言设置
|
|
|
+ private Object getDefaultValue(Object localeValue) {
|
|
|
+ if (localeValue instanceof OrmLocaleValue) {
|
|
|
+ OrmLocaleValue ormLocaleValue = (OrmLocaleValue) localeValue;
|
|
|
+ // 假设默认语言是 "zh_CN",你可以根据实际情况调整
|
|
|
+ return ormLocaleValue.get("zh_CN");
|
|
|
+ }
|
|
|
+ return localeValue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|