|
@@ -0,0 +1,181 @@
|
|
|
+package q1k2.pxlx.train.plugin.operate;
|
|
|
+
|
|
|
+import kd.bos.bill.BillShowParameter;
|
|
|
+import kd.bos.bill.OperationStatus;
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.entity.MulBasedataDynamicObjectCollection;
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
+import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
+import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
|
|
+import kd.bos.form.OpenStyle;
|
|
|
+import kd.bos.form.ShowType;
|
|
|
+import kd.bos.form.StyleCss;
|
|
|
+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 q1k2.pxlx.train.common.Q1k2MonthPlanLwConstant;
|
|
|
+import q1k2.pxlx.train.common.Q1k2YearPlanConstant;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description 年度计划操作插件
|
|
|
+ * @Created 刘维
|
|
|
+ */
|
|
|
+public class YearPlanOperationServicePlugIn extends AbstractOperationServicePlugIn implements Plugin {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
+ super.afterExecuteOperationTransaction(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单据数据已经提交到数据库之后,事务未提交之前,触发此事件;
|
|
|
+ *
|
|
|
+ * @remark 可以在此事件,进行数据同步处理;
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void endOperationTransaction(EndOperationTransactionArgs e) {
|
|
|
+ super.endOperationTransaction(e);
|
|
|
+ String operationKey = e.getOperationKey();
|
|
|
+ if ("submit".equals(operationKey)) {//提交
|
|
|
+ //判断 是否拆分月度计划
|
|
|
+ DynamicObject[] dataEntities = e.getDataEntities();
|
|
|
+ for (int i = 0; i < dataEntities.length; i++) {
|
|
|
+ //年度计划
|
|
|
+ DynamicObject yearPlan = dataEntities[i];
|
|
|
+ long yearPlanId = (long) yearPlan.getPkValue();
|
|
|
+ //查询数据
|
|
|
+ yearPlan = BusinessDataServiceHelper.loadSingle(yearPlanId, Q1k2YearPlanConstant.FORMBILLID);
|
|
|
+ //是否拆分月度计划
|
|
|
+ boolean isSplitmonthplan = yearPlan.getBoolean(Q1k2YearPlanConstant.Q1K2_SPLITMONTHPLAN);
|
|
|
+ //是否已经生成月度计划
|
|
|
+ boolean isGenerateMonth = yearPlan.getBoolean(Q1k2YearPlanConstant.Q1K2_GENERATE_MONTH);
|
|
|
+ if (isSplitmonthplan && !isGenerateMonth) {
|
|
|
+ //单据体
|
|
|
+ DynamicObjectCollection yearPlanItems = yearPlan.getDynamicObjectCollection(Q1k2YearPlanConstant.Q1K2_YEAR_PLAN_ITEM);
|
|
|
+ for (int j = 0; j < yearPlanItems.size(); j++) {
|
|
|
+ DynamicObject yearPlanItem = yearPlanItems.get(j);
|
|
|
+ for (int month = 1; month <= 12; month++) {
|
|
|
+ boolean isSelectMonth = yearPlanItem.getBoolean(Q1k2YearPlanConstant.Q1K2_ITEM_MONTH + month);
|
|
|
+ if (isSelectMonth) {
|
|
|
+ //生成月度计划
|
|
|
+ generateMonthPlan(j, month, yearPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yearPlan.set(Q1k2YearPlanConstant.Q1K2_GENERATE_MONTH, true);
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{yearPlan});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if ("unsubmit".equals(operationKey)) {
|
|
|
+ //撤销
|
|
|
+ DynamicObject[] dataEntities = e.getDataEntities();
|
|
|
+ for (int i = 0; i < dataEntities.length; i++) {
|
|
|
+ //年度计划
|
|
|
+ DynamicObject yearPlan = dataEntities[i];
|
|
|
+ //查询数据
|
|
|
+ yearPlan = BusinessDataServiceHelper.loadSingle(yearPlan.getPkValue(), Q1k2YearPlanConstant.FORMBILLID);
|
|
|
+ //是否拆分月度计划
|
|
|
+ boolean isSplitmonthplan = yearPlan.getBoolean(Q1k2YearPlanConstant.Q1K2_SPLITMONTHPLAN);
|
|
|
+ //是否已经生成月度计划
|
|
|
+ boolean isGenerateMonth = yearPlan.getBoolean(Q1k2YearPlanConstant.Q1K2_GENERATE_MONTH);
|
|
|
+ if (isSplitmonthplan && isGenerateMonth) {
|
|
|
+ QFilter qFilter = new QFilter(Q1k2MonthPlanLwConstant.Q1K2_YEAR_PLANID, "=", yearPlan.getPkValue());
|
|
|
+ DeleteServiceHelper.delete(Q1k2MonthPlanLwConstant.FORMBILLID, qFilter.toArray());
|
|
|
+ //更新 是否已经生成月度计划 为 否
|
|
|
+ yearPlan.set(Q1k2YearPlanConstant.Q1K2_GENERATE_MONTH, false);
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{yearPlan});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成月度计划
|
|
|
+ */
|
|
|
+ private void generateMonthPlan(int index, int month, DynamicObject yearPlan) {
|
|
|
+ long yearPlanId = (long) yearPlan.getPkValue();
|
|
|
+ //年度
|
|
|
+ String year = yearPlan.getString(Q1k2YearPlanConstant.Q1K2_YEAR);
|
|
|
+ DynamicObject yearPlanItem = yearPlan.getDynamicObjectCollection(Q1k2YearPlanConstant.Q1K2_YEAR_PLAN_ITEM).get(index);
|
|
|
+ DynamicObject monthPlan = BusinessDataServiceHelper.newDynamicObject(Q1k2MonthPlanLwConstant.FORMBILLID);
|
|
|
+
|
|
|
+ DynamicObject org = yearPlan.getDynamicObject(Q1k2YearPlanConstant.ORG);
|
|
|
+ //实施部门
|
|
|
+ DynamicObject itemorg = yearPlanItem.getDynamicObject(Q1k2YearPlanConstant.Q1K2_ITEM_ORG);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.ORG, org);
|
|
|
+ //年度计划
|
|
|
+ //String level = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_LEVEL);
|
|
|
+ //部门预算
|
|
|
+ //String budget = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_BUDGET);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_MONTH, month);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_YEAR, year);
|
|
|
+ //项目名称
|
|
|
+ String projectname = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_PROJECTNAME);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_NAME, projectname);//名称
|
|
|
+ //培训级别
|
|
|
+ String level = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_LEVEL);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_LEVEL, level);
|
|
|
+ //培训类型
|
|
|
+ String type = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_TYPE);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_TYPE, type);
|
|
|
+ //培训对象
|
|
|
+ String obj = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_OBJ);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_OBJECT, obj);
|
|
|
+ //培训主要内容
|
|
|
+ String content = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_CONTENT);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_CONTENT, content);
|
|
|
+ //培训形式
|
|
|
+ String trainingType = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_TRAININGTYPE);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_TRAINING_TYPE, trainingType);
|
|
|
+ //教师来源
|
|
|
+ String source = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_SOURCE);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_SOURCE, source);
|
|
|
+ //预算
|
|
|
+ BigDecimal budget = yearPlanItem.getBigDecimal(Q1k2YearPlanConstant.Q1K2_ITEM_BUDGET);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_BUDGE_SELF, budget);
|
|
|
+ //计划人数
|
|
|
+ BigDecimal count = yearPlanItem.getBigDecimal(Q1k2YearPlanConstant.Q1K2_ITEM_COUNT);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_USER, count);
|
|
|
+ //课时
|
|
|
+ BigDecimal hours = yearPlanItem.getBigDecimal(Q1k2YearPlanConstant.Q1K2_ITEM_HOURS);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_HOUR, hours);
|
|
|
+ //讲师
|
|
|
+ MulBasedataDynamicObjectCollection lecturers = (MulBasedataDynamicObjectCollection) yearPlanItem.getDynamicObjectCollection(Q1k2YearPlanConstant.Q1K2_ITEM_LECTURER);
|
|
|
+ MulBasedataDynamicObjectCollection monthlecturers = (MulBasedataDynamicObjectCollection) monthPlan.getDynamicObjectCollection(Q1k2MonthPlanLwConstant.Q1K2_LECTURER);
|
|
|
+ for (int i = 0; i < lecturers.size(); i++) {
|
|
|
+ DynamicObject user = (DynamicObject) lecturers.get(i).get("fbasedataid");
|
|
|
+ DynamicObject monthlecturer = monthlecturers.addNew();
|
|
|
+ monthlecturer.set("fbasedataid",user);
|
|
|
+ }
|
|
|
+ // monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_LECTURER, lecturers);
|
|
|
+ //天数
|
|
|
+ BigDecimal days = yearPlanItem.getBigDecimal(Q1k2YearPlanConstant.Q1K2_ITEM_DAYS);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_DAYS, days);
|
|
|
+ //地点
|
|
|
+ String address = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_ADDRESS);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_ADDRESS, address);
|
|
|
+ //联系人
|
|
|
+ String contacts = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_CONTACTS);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_CONTACTS, contacts);
|
|
|
+ //联系电话
|
|
|
+ String phone = yearPlanItem.getString(Q1k2YearPlanConstant.Q1K2_ITEM_PHONE);
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_TELEPHONEFIELD, phone);
|
|
|
+ //实施状态
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_EXEC_STATUS, "NOT_START");
|
|
|
+ //计划来源
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_ORIGIN, "YEAR");
|
|
|
+ //年度计划id
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.Q1K2_YEAR_PLANID, yearPlanId);
|
|
|
+ //状态更新为已提交
|
|
|
+ monthPlan.set(Q1k2MonthPlanLwConstant.BILLSTATUS, "B");
|
|
|
+ //保存
|
|
|
+ SaveServiceHelper.saveOperate(Q1k2MonthPlanLwConstant.FORMBILLID, new DynamicObject[]{monthPlan}, OperateOption.create());
|
|
|
+ }
|
|
|
+}
|