|
@@ -5,6 +5,7 @@ import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.resource.ResManager;
|
|
import kd.bos.dataentity.resource.ResManager;
|
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
|
|
+import kd.bos.form.operate.AbstractOperate;
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QCP;
|
|
@@ -30,57 +31,65 @@ public class ErDailyReimburseExtBotpUpPlugin extends PublicReimburseBotpUpPlugin
|
|
private static Long filter_projectid = 0L;
|
|
private static Long filter_projectid = 0L;
|
|
|
|
|
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
|
|
+
|
|
|
|
+ Object source = args.getSource();
|
|
|
|
+
|
|
|
|
+ String opKey = ((AbstractOperate)source).getOperateKey();
|
|
DynamicObject company = null;
|
|
DynamicObject company = null;
|
|
- if (this.getControl("company") != null) {
|
|
|
|
- company = (DynamicObject)this.getModel().getValue("company");
|
|
|
|
- } else if (this.getView().getParentView().getControl("company") != null) {
|
|
|
|
- company = (DynamicObject)this.getView().getParentView().getModel().getValue("company");
|
|
|
|
- }
|
|
|
|
- Long companyId = company == null ? null : (Long)company.getPkValue();
|
|
|
|
- companyId = companyId != null ? companyId : RequestContext.get().getOrgId();
|
|
|
|
- String controlproject = (String) ErCommonUtils.getEMParameter(companyId, "nckd_controlproject");
|
|
|
|
-
|
|
|
|
- DynamicObject item = (DynamicObject) this.getModel().getValue("nckd_expenseitem");
|
|
|
|
-
|
|
|
|
- if (item == null) {
|
|
|
|
- this.getView().showTipNotification(ResManager.loadKDString("请先选择费用类型。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
- args.setCancel(true);
|
|
|
|
- } else if("1".equals(controlproject)){
|
|
|
|
- item = BusinessDataServiceHelper.loadSingle(item.getPkValue(), item.getDynamicObjectType().getName());
|
|
|
|
-
|
|
|
|
- String isrelapjtype = item.getString("nckd_isrelapjtype");
|
|
|
|
- String pjtype = item.getString("nckd_pjtype");
|
|
|
|
- String isrelapj = (String) this.getModel().getValue("nckd_isrelapj");
|
|
|
|
-
|
|
|
|
- //必选
|
|
|
|
- if("1".equals(isrelapjtype) || ("2".equals(isrelapjtype) && "1".equals(isrelapj))){
|
|
|
|
- //标准项目
|
|
|
|
- if("project".equals(pjtype)){
|
|
|
|
- if(this.getModel().getValue("nckd_project") == null) {
|
|
|
|
- this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
- args.setCancel(true);
|
|
|
|
- } else {
|
|
|
|
- filter_projectfield = "nckd_project";
|
|
|
|
- filter_projectid = ((DynamicObject) this.getModel().getValue("nckd_project")).getLong("id");
|
|
|
|
-
|
|
|
|
- checkproject = true;
|
|
|
|
-
|
|
|
|
- super.beforeDoOperation(args);
|
|
|
|
|
|
+ if("addapplycheck".equals(opKey)) {
|
|
|
|
+ if (this.getControl("company") != null) {
|
|
|
|
+ company = (DynamicObject) this.getModel().getValue("company");
|
|
|
|
+ } else if (this.getView().getParentView().getControl("company") != null) {
|
|
|
|
+ company = (DynamicObject) this.getView().getParentView().getModel().getValue("company");
|
|
|
|
+ }
|
|
|
|
+ Long companyId = company == null ? null : (Long) company.getPkValue();
|
|
|
|
+ companyId = companyId != null ? companyId : RequestContext.get().getOrgId();
|
|
|
|
+ String controlproject = (String) ErCommonUtils.getEMParameter(companyId, "nckd_controlproject");
|
|
|
|
+
|
|
|
|
+ DynamicObject item = (DynamicObject) this.getModel().getValue("nckd_expenseitem");
|
|
|
|
+
|
|
|
|
+ if (item == null) {
|
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("请先选择费用类型。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
+ args.setCancel(true);
|
|
|
|
+ } else if ("1".equals(controlproject)) {
|
|
|
|
+ item = BusinessDataServiceHelper.loadSingle(item.getPkValue(), item.getDynamicObjectType().getName());
|
|
|
|
+
|
|
|
|
+ String isrelapjtype = item.getString("nckd_isrelapjtype");
|
|
|
|
+ String pjtype = item.getString("nckd_pjtype");
|
|
|
|
+ String isrelapj = (String) this.getModel().getValue("nckd_isrelapj");
|
|
|
|
+
|
|
|
|
+ //必选
|
|
|
|
+ if ("1".equals(isrelapjtype) || ("2".equals(isrelapjtype) && "1".equals(isrelapj))) {
|
|
|
|
+ //标准项目
|
|
|
|
+ if ("project".equals(pjtype)) {
|
|
|
|
+ if (this.getModel().getValue("nckd_project") == null) {
|
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
+ args.setCancel(true);
|
|
|
|
+ } else {
|
|
|
|
+ filter_projectfield = "nckd_project";
|
|
|
|
+ filter_projectid = ((DynamicObject) this.getModel().getValue("nckd_project")).getLong("id");
|
|
|
|
+
|
|
|
|
+ checkproject = true;
|
|
|
|
+
|
|
|
|
+ super.beforeDoOperation(args);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //核算项目
|
|
|
|
- else if("acctitem".equals(pjtype)){
|
|
|
|
- if(this.getModel().getValue("nckd_acctitem") == null) {
|
|
|
|
- this.getView().showTipNotification(ResManager.loadKDString("请先选择核算项目。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
- args.setCancel(true);
|
|
|
|
- } else {
|
|
|
|
- filter_projectfield = "nckd_acctitem";
|
|
|
|
- filter_projectid = ((DynamicObject) this.getModel().getValue("nckd_acctitem")).getLong("id");
|
|
|
|
-
|
|
|
|
- checkproject = true;
|
|
|
|
-
|
|
|
|
- super.beforeDoOperation(args);
|
|
|
|
|
|
+ //核算项目
|
|
|
|
+ else if ("acctitem".equals(pjtype)) {
|
|
|
|
+ if (this.getModel().getValue("nckd_acctitem") == null) {
|
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("请先选择核算项目。", "PublicReimburseBotpUpPlugin_0", "fi-er-formplugin", new Object[0]));
|
|
|
|
+ args.setCancel(true);
|
|
|
|
+ } else {
|
|
|
|
+ filter_projectfield = "nckd_acctitem";
|
|
|
|
+ filter_projectid = ((DynamicObject) this.getModel().getValue("nckd_acctitem")).getLong("id");
|
|
|
|
+
|
|
|
|
+ checkproject = true;
|
|
|
|
+
|
|
|
|
+ super.beforeDoOperation(args);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ super.beforeDoOperation(args);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
super.beforeDoOperation(args);
|
|
super.beforeDoOperation(args);
|
|
@@ -122,11 +131,16 @@ public class ErDailyReimburseExtBotpUpPlugin extends PublicReimburseBotpUpPlugin
|
|
|
|
|
|
List<String> removeApplys = new ArrayList<>();
|
|
List<String> removeApplys = new ArrayList<>();
|
|
DynamicObject[] applys = BusinessDataServiceHelper.load(entityName, selectFileds, qFilter.toArray());
|
|
DynamicObject[] applys = BusinessDataServiceHelper.load(entityName, selectFileds, qFilter.toArray());
|
|
|
|
+
|
|
|
|
+ log.info("itemIds:" + itemIds.toString());
|
|
|
|
+ log.info("checkproject:" + checkproject);
|
|
for(DynamicObject apply : applys){
|
|
for(DynamicObject apply : applys){
|
|
boolean needRemove = false;
|
|
boolean needRemove = false;
|
|
|
|
|
|
Long itemId = apply.getDynamicObject("nckd_expenseitem").getLong("id");
|
|
Long itemId = apply.getDynamicObject("nckd_expenseitem").getLong("id");
|
|
|
|
|
|
|
|
+ log.info("itemId:" + itemId + "; billno:" + apply.getString("billno"));
|
|
|
|
+
|
|
//过滤费用项目
|
|
//过滤费用项目
|
|
if(!itemIds.contains(itemId)){
|
|
if(!itemIds.contains(itemId)){
|
|
needRemove = true;
|
|
needRemove = true;
|
|
@@ -145,7 +159,7 @@ public class ErDailyReimburseExtBotpUpPlugin extends PublicReimburseBotpUpPlugin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- log.info("removeApplys" + removeApplys.toString());
|
|
|
|
|
|
+ log.info("removeApplys:" + removeApplys.toString());
|
|
|
|
|
|
for(int i = billlists1.size()-1; i >= 0; i--){
|
|
for(int i = billlists1.size()-1; i >= 0; i--){
|
|
Map<String, Object> map = billlists1.get(i);
|
|
Map<String, Object> map = billlists1.get(i);
|