|
|
@@ -1,7 +1,10 @@
|
|
|
package nckd.jxccl.hr.tsc.plugin.form;
|
|
|
|
|
|
-import kd.bos.context.RequestContext;
|
|
|
+import kd.bos.algo.DataSet;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.db.DB;
|
|
|
+import kd.bos.db.DBRoute;
|
|
|
import kd.bos.entity.EntityMetadataCache;
|
|
|
import kd.bos.entity.MainEntityType;
|
|
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|
|
@@ -9,16 +12,24 @@ import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
import kd.bos.form.events.SetFilterEvent;
|
|
|
import kd.bos.form.operate.FormOperate;
|
|
|
import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
+import kd.bos.orm.ORM;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
-import kd.bos.servicehelper.model.PermissionStatus;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
import kd.bos.servicehelper.user.UserServiceHelper;
|
|
|
-import kd.sdk.hr.hbp.business.helper.permission.HRPermissionServiceHelper;
|
|
|
+import kd.hr.hbp.common.util.HRStringUtils;
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
+import nckd.jxccl.base.swc.helper.SWCHelper;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 政策公告列表插件
|
|
|
@@ -28,6 +39,59 @@ import java.util.HashMap;
|
|
|
@SuppressWarnings("unused")
|
|
|
public class AnnouncementsListPlugin extends AbstractListPlugin implements Plugin {
|
|
|
|
|
|
+ private static final Log logger = LogFactory.getLog(AnnouncementsListPlugin.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setFilter(SetFilterEvent e) {
|
|
|
+ super.setFilter(e);
|
|
|
+ List<QFilter> qFilters = e.getQFilters();
|
|
|
+ List<QFilter> qFilterList = null;
|
|
|
+ if(qFilters.size()>0 && qFilters.get(0) != null) {
|
|
|
+ qFilterList = (List) qFilters.stream().filter((qFilter) -> {
|
|
|
+ return HRStringUtils.equals(qFilter.getProperty(), "id");
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ QFilter qFilter = null;
|
|
|
+ Long userId = UserServiceHelper.getCurrentUserId();
|
|
|
+ DynamicObject personUserDyn = SWCHelper.queryOne(FormConstant.HRPI_PERSONUSERREL, "employee.id","user",userId);
|
|
|
+
|
|
|
+ Long empId = 0L;
|
|
|
+ if(personUserDyn == null){
|
|
|
+ /**
|
|
|
+ * 没有员工信息时,返回常量,用于测试
|
|
|
+ */
|
|
|
+ //empId = 2313784485549715456L;
|
|
|
+ this.getView().showMessage("未找到员工!");
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ empId = personUserDyn.getLong("employee.id");
|
|
|
+ }
|
|
|
+ List<Long> employeeIds = new java.util.ArrayList<>();
|
|
|
+ employeeIds.add(empId);
|
|
|
+ DynamicObject[] empDyns = SWCHelper.queryEmpPosOrgRelDyns(employeeIds);
|
|
|
+ if(empDyns != null && empDyns.length > 0){
|
|
|
+ ///获取当前员工的行政组织长编码
|
|
|
+ Long companyId = empDyns[0].getLong("company.id");
|
|
|
+ logger.info("AnnouncementsListPlugin currEmpId:" + empId + " companyId:"+ companyId);
|
|
|
+ qFilter = new QFilter("nckd_hradminorg.id", QCP.equals, companyId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (qFilterList == null && qFilter != null) {
|
|
|
+ //qFilter = new QFilter("number", QCP.equals, "在地愿为连理枝");
|
|
|
+ qFilters.add(qFilter);
|
|
|
+ }else{
|
|
|
+ //qFilter = new QFilter("number", QCP.equals, "在地愿为连理枝");
|
|
|
+ //qFilter = new QFilter("id", QCP.equals, 2392305707270548480L);
|
|
|
+ qFilter = new QFilter("id", QCP.equals, 10000000000000000L);
|
|
|
+ qFilters.add(qFilter);
|
|
|
+ }
|
|
|
+ e.setOrderBy("nckd_istop Desc,nckd_publishdate Desc");
|
|
|
+
|
|
|
+ logger.info("AnnouncementsListPlugin setFilters:" + e.getQFilters().toString() );
|
|
|
+ }
|
|
|
+
|
|
|
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
|
|
super.afterDoOperation(args);
|
|
|
FormOperate formOperate = (FormOperate)args.getSource();
|