This commit is contained in:
parent
951e8999a8
commit
d220d45211
|
@ -0,0 +1,138 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.ec.eceq.common.enums.EquipmentUseStatusEnum;
|
||||
import kd.ec.eceq.common.enums.UseStatusEnum;
|
||||
import kd.ec.eceq.opplugin.EquipmentHelper;
|
||||
import kd.ec.eceq.opplugin.validator.EquipExitValidator;
|
||||
|
||||
public class EquipmentExitOpExt extends AbstractOperationServicePlugIn {
|
||||
public EquipmentExitOpExt() {
|
||||
}
|
||||
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("exitdate");
|
||||
e.getFieldKeys().add("entryentity");
|
||||
e.getFieldKeys().add("equipmentid");
|
||||
e.getFieldKeys().add("equipsnapshot_tag");
|
||||
e.getFieldKeys().add("approachrow");
|
||||
e.getFieldKeys().add("approachid");
|
||||
}
|
||||
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
e.addValidator(new EquipExitValidator());
|
||||
}
|
||||
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
switch (e.getOperationKey()) {
|
||||
case "audit":
|
||||
this.doAudit(e);
|
||||
break;
|
||||
case "unaudit":
|
||||
this.doUnAudit(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doAudit(BeforeOperationArgs e) {
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
if (dataEntities.length > 0) {
|
||||
DynamicObject[] var3 = dataEntities;
|
||||
int var4 = dataEntities.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
DynamicObject entity = var3[var5];
|
||||
Date exitDate = entity.getDate("exitdate");
|
||||
DynamicObjectCollection entry = entity.getDynamicObjectCollection("entryentity");
|
||||
ArrayList<DynamicObject> updateList = new ArrayList();
|
||||
ArrayList<DynamicObject> updateApproachList = new ArrayList();
|
||||
Iterator var11 = entry.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
DynamicObject row = (DynamicObject)var11.next();
|
||||
long approachRowId = row.getLong("approachrow");
|
||||
DynamicObject approachEquip = BusinessDataServiceHelper.loadSingle(approachRowId, "eceq_approachequipf7");
|
||||
boolean isExit = approachEquip.getBoolean("isexit");
|
||||
if (!isExit) {
|
||||
approachEquip.set("isexit", true);
|
||||
approachEquip.set("exitdate", exitDate);
|
||||
updateApproachList.add(approachEquip);
|
||||
DynamicObject equipment = row.getDynamicObject("equipmentid");
|
||||
if (equipment != null) {
|
||||
JSONObject snapshot = EquipmentHelper.generateSnapshot(equipment);
|
||||
row.set("equipsnapshot_tag", snapshot.toJSONString());
|
||||
String property = equipment.getString("property");
|
||||
equipment.set("equipstatus", EquipmentUseStatusEnum.FREE.getValue());
|
||||
equipment.set("usestatus", UseStatusEnum.EXITED.getValue());
|
||||
equipment.set("project", (Object)null);
|
||||
equipment.set("useorg", (Object)null);
|
||||
equipment.set("approachdate", (Object)null);
|
||||
equipment.set("exitdate", exitDate);
|
||||
updateList.add(equipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SaveServiceHelper.update((DynamicObject[])updateList.toArray(new DynamicObject[0]));
|
||||
SaveServiceHelper.update((DynamicObject[])updateApproachList.toArray(new DynamicObject[0]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void doUnAudit(BeforeOperationArgs e) {
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
if (dataEntities.length > 0) {
|
||||
DynamicObject[] var3 = dataEntities;
|
||||
int var4 = dataEntities.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
DynamicObject entity = var3[var5];
|
||||
DynamicObjectCollection entry = entity.getDynamicObjectCollection("entryentity");
|
||||
ArrayList<DynamicObject> updateList = new ArrayList();
|
||||
ArrayList<DynamicObject> updateApproachList = new ArrayList();
|
||||
Iterator var10 = entry.iterator();
|
||||
|
||||
while(var10.hasNext()) {
|
||||
DynamicObject row = (DynamicObject)var10.next();
|
||||
long approachRowId = row.getLong("approachrow");
|
||||
DynamicObject approachEquip = BusinessDataServiceHelper.loadSingle(approachRowId, "eceq_approachequipf7");
|
||||
boolean isExit = approachEquip.getBoolean("isexit");
|
||||
if (isExit) {
|
||||
approachEquip.set("isexit", false);
|
||||
approachEquip.set("exitdate", (Object)null);
|
||||
updateApproachList.add(approachEquip);
|
||||
DynamicObject equipment = row.getDynamicObject("equipmentid");
|
||||
if (equipment != null) {
|
||||
String equipSnapshotJsonStr = row.getString("equipsnapshot_tag");
|
||||
JSONObject snapshot = JSONObject.parseObject(equipSnapshotJsonStr);
|
||||
EquipmentHelper.recoverBySnapshot(equipment, snapshot);
|
||||
updateList.add(equipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SaveServiceHelper.update((DynamicObject[])updateList.toArray(new DynamicObject[0]));
|
||||
SaveServiceHelper.update((DynamicObject[])updateApproachList.toArray(new DynamicObject[0]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue